I'm trying to build a saved search formula that says if the invoice has no email/message attached or if the LATEST email recipient is not the same as the customer on the invoice, then show 0 else 1. I'm getting an invalid expression error.
CASE WHEN {messages.internalid} IS NULL OR (MAX({messages.messagedate}) AND {messages.recipient} != (CASE WHEN {customermain.isperson} = 'F' THEN {customermain.entityid} || ' ' || {customer.companyname} ELSE {customermain.entityid} || ' ' || {customer.firstname} || ' ' || {customer.lastname} END)) THEN 0 ELSE 1 END