Files
Drew McLellan 1d9808ab8b fix(studio): name the organization in the overdue invoices banner (#51747)
## Problem

The "Outstanding invoices in other organization" banner asks users to
pay invoices to avoid service disruption, but never says which
organization has them. Users with several organizations have to guess
where to go.

The banner also looked at only the first overdue organization. Its link
pointed at that organization's billing page without naming it, and if
the lookup failed, it fell back to the current organization's billing
page.

Linear: FE-4587

## Solution

- `useOrganizationRestrictions` now collects every other organization
with overdue invoices from the organizations list. It dedupes them,
excludes the current one, and orders them by name, which the list
already is. It no longer falls back to the current organization's slug.
- The banner names only the first organization, linked to its billing
page: "Pay invoices for **Acme** to avoid service disruption". When more
organizations are affected it adds a count: "…for **Acme** and 2
others…". Paying the first often clears the rest, and the next one
appears once it's resolved.
- If no affected organization can be resolved, for example the user lost
access, the banner shows "Pay outstanding invoices to avoid service
disruption", linking to `/organizations`.
- The title is now plural: "Outstanding invoices in other
organizations".
- The dev toolbar's "overdue invoices from other org" override now
injects overdue invoices for every real other organization. It
previously used a made-up ID, so the banner could never show a name. I
also replaced a nested ternary there, per Studio's style rules.


For one org:
<img width="1022" height="42" alt="Screenshot 2026-10-14 at 12 01 32"
src="https://github.com/user-attachments/assets/8f34c2ff-d47f-45fc-80a4-c7cdc3df558b"
/>

For multiple orgs:
<img width="1057" height="42" alt="Screenshot 2026-10-14 at 13 39 42"
src="https://github.com/user-attachments/assets/2100b0b5-65a3-4d7c-8521-48d8e71b62ef"
/>

Note: Overdue invoice counts are not shown by design, only that one or
more overdue invoices exist for an org.

## Review instructions

1. Run Studio in platform mode with at least three organizations, and
open a project page.
2. Enable the dev toolbar from the account menu ("Local tools" > "Dev
toolbar").
3. In the Warnings tab when on a Project page, choose "Overdue invoices
from other org".
4. Check that the banner names the first other organization
alphabetically, shows "and N others" when there's more than one, and
that the name links to that organization's billing page.
5. Use "Reset to real data" to clear the override.

Tests: `pnpm --filter studio exec vitest run
components/interfaces/Organization/restriction.constants.test.tsx
hooks/misc/useOrganizationRestrictions.test.tsx`

### Mocking in QA

Mock `/platform/stripe/invoices/overdue` for overdue invoice counts in
different organizations.
Note: The endpoint will not return an org in the result if the overdue
invoice count is zero.

## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
(not applicable)
2026-10-15 12:45:30 +01:00
..