def METHOD_NAME(request):
    """Return all the organizations for which the user has a privileged role."""
    organizations_managed = (
        request.db.query(Organization.id)
        .join(OrganizationRole.organization)
        .filter(
            OrganizationRole.role_name == OrganizationRoleType.Manager,
            OrganizationRole.user == request.user,
        )
        .subquery()
    )
    organizations_owned = (
        request.db.query(Organization.id)
        .join(OrganizationRole.organization)
        .filter(
            OrganizationRole.role_name == OrganizationRoleType.Owner,
            OrganizationRole.user == request.user,
        )
        .subquery()
    )
    organizations_billing = (
        request.db.query(Organization.id)
        .join(OrganizationRole.organization)
        .filter(
            OrganizationRole.role_name == OrganizationRoleType.BillingManager,
            OrganizationRole.user == request.user,
        )
        .subquery()
    )
    organizations_with_sole_owner = (
        request.db.query(OrganizationRole.organization_id)
        .join(organizations_owned)
        .filter(OrganizationRole.role_name == "Owner")
        .group_by(OrganizationRole.organization_id)
        .having(func.count(OrganizationRole.organization_id) == 1)
        .subquery()
    )
    return {
        "organizations_owned": (
            request.db.query(Organization)
            .join(organizations_owned, Organization.id == organizations_owned.c.id)
            .order_by(Organization.name)
            .all()
        ),
        "organizations_managed": (
            request.db.query(Organization)
            .join(organizations_managed, Organization.id == organizations_managed.c.id)
            .order_by(Organization.name)
            .all()
        ),
        "organizations_billing": (
            request.db.query(Organization)
            .join(organizations_billing, Organization.id == organizations_billing.c.id)
            .order_by(Organization.name)
            .all()
        ),
        "organizations_with_sole_owner": (
            request.db.query(Organization)
            .join(
                organizations_with_sole_owner,
                Organization.id == organizations_with_sole_owner.c.organization_id,
            )
            .order_by(Organization.name)
            .all()
        ),
    }