hide record from the popup list/ popup search based on the filed value

which file has to edit???
which code has to write…??

I have two custom modules one is “Trainer” and Another one is “Batches”.

My question :

I am able to assign many trainers to many batches. but there is the small trick here

if one batch assigns to the trainer, that trainer has to hide from the popup filter/look up when creating another batch.
one trainer able to attend only one batch at a time. and another batch that trainer won’t be available.

anyone one little help here…