Could be that one or two engine macros do not work properly, I don’t know. These work:
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) // Do not Print in Shipping or Test
// Execute code here.
#endif
Related topics:
https://www.reddit.com/r/unrealengine/comments/f6epk2/any_way_to_tell_from_blueprint_or_c_what_kind_of/