It doesn’t work like that because the expression of this type resolves to either true or false which is then gets converted into a string "true" or "false" and only then the node checks if this string contains "an".
You need switch to complete logical expressions in logical comparison context.
E.g.
Also if you want that “John” would trigger both outputs you need to turn on an option for this: