01 · Before and afterThe pattern
// before
const recipients = selected.filter(isStillMember);
return recipients.length ? recipients : [ALL_PROJECT_MEMBERS]; // empty -> everyone
// after
if (selected.length > 0 && recipients.length === 0)
throw new BadRequestError("Recipients left the project; choose recipients again");02 · Run it on your appThe check
In your app, can a filter that removes every recipient quietly turn into “send to everyone”?
If the honest answer is no or not sure, this is worth a look before it reaches production.