I have two formulas on Google Sheets which works as expected:
=AND(IFERROR(MATCH($A1,INDIRECT("Sheet2!A:A"),false),0)=0,$B1="Yes")