I believe the syntax error is due to this:
The syntax analyzer for IIF expects an expression so will parse it as such. You have a quoted string constant ("Morning") followed by an equal sign (=) so the thing that follows the equals sign will have to produce the word "Morning" in order to be true. But the thing that follows the equals sign is an unquoted word followed by a space and an opening parenthesis that is part of a longer expression. By rules of syntax, "(x..." introduces a parenthetical expression that, when resolved, will yield a value. That word "ANY" (not quoted) is treated like a value because you have nothing in that context to say otherwise. So what you have is syntactically seen as <value> <space> <value>. The syntax error normally would be "missing operator" but because it is inside a library function, the specific error is masked and the function instead returns the generic "Synax Error."
The problem is that in that context, "ANY" isn't being treated as a query element or keyword. It is in the context of an expression (because it is inside a function that expects expressions.)