For email templates, when the initial message construction starts, the variable $user is not yet set, as the substitution phase occurs after evaluating the IF/ELSE logic blocks. So, at the point where the comparisons are being made, the $user variable doesn’t contain any data, and this is what causes the non-matching behavior you are seeing. This explains why the test email works, because the $user variable DOES exist when it is processed that way (the test uses the current user info).
To correct this, we will need to rework how the templates get processed, which will take some time (in other words, not a quick fix, as the work will need to be scoped, assigned, worked, and tested). I’ve created a development ticket for the appropriate team and will be monitoring their progress.
I don’t have any timeline yet when this will be fixed, but I’ll update this thread as I have additional information. Thanks for your patience, and please feel free to ask any questions you have.