code: def is_group_manager(user, group=None):
      
      roles = get_user_roles(user)
      return any(x[1] == TenantRole.ROLE_GROUP_MANAGER and (not group or x[0] == group) for x in roles)
docs: Returns True if user is a group manager either for the group or any group.