Problem
On /admin/clients, the TEAM CLIENTS member count is inflated by 1 — it counts the hidden provisioning service account. A team with one Team Lead and no designers shows "2 members" instead of 1. Found 2026-05-29 testing "Prod Test Co".
Root cause
src/app/api/admin/clients/route.ts line 62:
membersCount: org.membersCount ?? 0,
This is Clerk's raw membersCount (from includeMembersCount: true). Every provisioned org has the service account as a member (it's createdBy / owner), so the count is always +1. The roster list correctly filters the service account via isProvisioningUser, but the count here doesn't.
Proposed fix
Subtract the service account when the org was provisioned by it:
const provisioner = provisioningUserId();
const raw = org.membersCount ?? 0;
const membersCount =
provisioner && org.createdBy === provisioner ? Math.max(0, raw - 1) : raw;
Using the createdBy === provisioner guard (rather than a blanket -1) keeps legacy/non-provisioned orgs accurate. Cheap — no extra Clerk calls.
Priority
Before the client demo — an inflated member count is confusing in the provisioning view Ward will demo.
Problem
On
/admin/clients, the TEAM CLIENTS member count is inflated by 1 — it counts the hidden provisioning service account. A team with one Team Lead and no designers shows "2 members" instead of 1. Found 2026-05-29 testing "Prod Test Co".Root cause
src/app/api/admin/clients/route.tsline 62:This is Clerk's raw
membersCount(fromincludeMembersCount: true). Every provisioned org has the service account as a member (it'screatedBy/ owner), so the count is always +1. The roster list correctly filters the service account viaisProvisioningUser, but the count here doesn't.Proposed fix
Subtract the service account when the org was provisioned by it:
Using the
createdBy === provisionerguard (rather than a blanket-1) keeps legacy/non-provisioned orgs accurate. Cheap — no extra Clerk calls.Priority
Before the client demo — an inflated member count is confusing in the provisioning view Ward will demo.