(user, roles_qs)
return roles_qs.filter(
            id__in=RoleAncestorEntry.objects.filter(
                descendent__in=RoleAncestorEntry.objects.filter(ancestor_id__in=list(user.roles.values_list('id', flat=True))).values_list(
                    'descendent', flat=True
                )
            )
            .distinct()
            .values_list('ancestor', flat=True)
        )
Visible roles include all roles that are ancestors of any
        roles that the user has access to.
        Case in point - organization auditor_role must see all roles
        in their organization, but some of those roles descend from
        organization admin_role, but not auditor_role.
Visible roles include all roles that are ancestors of any
        roles that the user has access to.
        Case in point - organization auditor_role must see all roles
        in their organization, but some of those roles descend from
        organization admin_role, but not auditor_role.
Visible roles include all roles that are ancestors of any roles that the user has access to . Case in point - organization auditor_role must see all roles in their organization but some of those roles descend from organization admin_role but not auditor_role .
def filter_visible_roles(user, roles_qs):
        """
        Visible roles include all roles that are ancestors of any
        roles that the user has access to.
        Case in point - organization auditor_role must see all roles
        in their organization, but some of those roles descend from
        organization admin_role, but not auditor_role.
        """
        return roles_qs.filter(
            id__in=RoleAncestorEntry.objects.filter(
                descendent__in=RoleAncestorEntry.objects.filter(ancestor_id__in=list(user.roles.values_list('id', flat=True))).values_list(
                    'descendent', flat=True
                )
            )
            .distinct()
            .values_list('ancestor', flat=True)
        )
def filter_visible_roles ( user , roles_qs ) : return roles_qs . filter ( id__in = RoleAncestorEntry . objects . filter ( descendent__in = RoleAncestorEntry . objects . filter ( ancestor_id__in = list ( user . roles . values_list ( 'id' , flat = True ) ) ) . values_list ( 'descendent' , flat = True ) ) . distinct ( ) . values_list ( 'ancestor' , flat = True ) )