Hello,
First of all you don't need to wrap boolean function into if(), you can use isUserMemberOfGroup() directly. It should work.
The error you have because this node is not user input and loggedInUser() doesn't return a correct value for isUserMemberOfGroup…