Filter associated record selection based on condition

I’d like to apply a condition where users cannot associate a record with a certain other record based on criteria. EG can’t associate new line items with a closed deal, or can only associate a custom object with a deal that is x, y or z.

Ideally the records that don’t meet the criteria simply don’t appear in the list.