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