TOP-4879: accountName Field — Investigation Findings
Problem
The Manage page search displays two fields for each company: Company (current default child company name) and Account (the original name from signup). Many entries show “Account: null” because the accountName field is missing from both the Fauna root company document and the Algolia manage index.
This means operators cannot find these companies by their original account name — which is the whole purpose of the field.
Impact
Out of 1,039 root companies in Fauna:
| Metric | Count | % |
|---|---|---|
With accountName | 423 | 41% |
Without accountName | 616 | 59% |
Of the 616 missing, ~60 are test/fake accounts and ~18 are unlikely to be real businesses. That leaves roughly 538 real companies affected.
Activity breakdown (based on lastLogin field, updated on every login by any user role):
| Last login | Count | Cumulative |
|---|---|---|
| Within last month | 148 | 148 |
| 1–3 months ago | 62 | 210 |
| 3–6 months ago | 50 | 260 |
| 6–12 months ago | 86 | 346 |
| Over a year ago or never | 270 | 616 |
148 active companies (logged in within the last month) are affected right now.
Root Cause
accountName is only written by updateCompanyX in server/graphql/resolvers/lib/rootQueries.js. This function fires when a child company marked as default: true is created or updated — which happens during onboarding (OnBoardQuiz) and when editing companies in Settings.
The value comes from context.settings.companyName, which is set once at signup (in addInitialData) and is effectively immutable (the UI field is disabled).
The gap: when accountName was introduced (2025-09-30), all companies created before that date needed a retroactive backfill. A backfill script was written but likely never completed successfully (see History below). Companies onboarded after that date get accountName through the normal onboarding flow, but the ~616 older companies were left behind.
Evidence
Companies with accountName — the value matches settings.companyName in the tenant database, confirming the field is correctly derived:
| Root company name | accountName | settings.companyName |
|---|---|---|
| MAXCARTRAVEL, LDA | Jarotrans-cz S.R.O. | Jarotrans-cz S.R.O. |
| Laflei SL | Rent Luxe Car | Rent Luxe Car |
Companies without accountName — all have their last root doc update before 2025-09-30, meaning updateCompanyX was never called for them after the feature was introduced:
| Root company name | Created | Last updated |
|---|---|---|
| DeGa Auto GmbH | 2023-07-16 | 2025-09-09 |
| Demo Company | 2022-08-15 | never |
| AeroPark Palermo | 2023-07-28 | 2023-07-28 |
| Click n Rent | 2023-08-01 | 2023-08-01 |
| GIUNGOAUTO SAS | 2023-08-02 | 2025-07-15 |
Example — “ALPHABET Rent” (ranieri_auto_srl_...): The root company doc in Fauna has no accountName field at all. The tenant’s settings.companyName is “RANIERI AUTO SRL” — so operators searching “Ranieri” get no results, even though the company is active.
History
2025-09-30 — accountName introduced
Commit: 9f6c2fe79 — “Missislecter/top 3923 search in manage page doesnt find companies (#5288)”
Added accountName to updateCompanyX (both Fauna update and Algolia indexing) and created a one-off backfill endpoint (pages/api/dev/update-default-companies.js).
2025-10-09 — Minor logging changes
Commits: 6454752da, 6b3b8ec7c — cosmetic log changes to the backfill script.
2025-11-06 — Dual-write migration
Commit: a862238b6 — backfill script updated to also write to Upstash Search alongside Algolia.
2026-04-17 — Backfill endpoint deleted
Commit: da7eac374 — deleted along with other /api/dev endpoints in a security cleanup. No replacement was created.
Backfill script issues
The script (update-default-companies.js) had structural flaws:
-
Fauna update was unbatched, Algolia update was batched:
getActiveCompanies()updated ALL Fauna docs on every call, but only a slice (controlled bybatchNumber/batchSize, defaulting to 10) was sent to Algolia. Multiple calls were needed for full coverage, with redundant Fauna updates each time. -
partialUpdateObjectsinstead ofsaveObjects: Companies not already in the Algolia index would be silently skipped. -
No completion tracking: No way to verify all batches were processed or resume from failure.
The backfill almost certainly never ran
The Fauna update in getActiveCompanies() was unbatched — a single invocation would have written accountName to every company in the database, regardless of the batchNumber/batchSize parameters. Despite this, 616 out of 1,039 companies (59%) still have no accountName field at all — not null, not empty, simply absent from the document. If the script had been called even once, all Fauna documents would have the field. This strongly indicates the endpoint was deployed but never invoked.
Additional Findings
settings.companyName is not truly immutable (follow-up ticket)
The Account Name field is disabled in the UI (components/pages/Settings/UserProfile/Account.js:134), but companyName is part of the SettingsInput GraphQL type (server/graphql/schema/settings.graphql:299) and the updateSettings resolver (server/graphql/resolvers/mutation/updateSettings.resolver.js:96) passes the entire input straight to Fauna without field filtering. This means settings.companyName can be changed via a direct GraphQL mutation, bypassing the UI guard. This should be addressed in a separate ticket.
accountName is redundantly overwritten on every company update (this ticket)
updateCompanyX writes accountName: settings.companyName on every call — both the create and update paths. Since accountName is meant to be immutable, this is unnecessary. Its correctness relies entirely on the assumption that settings.companyName never changes — an assumption that is not enforced server-side (see above). updateCompanyX should only set accountName when creating a new root company document, not when updating an existing one.
Root company vs child company: a design concern (future review)
The current design syncs the root company document with the tenant’s default child company — every field (name, email, phone, logo, etc.) is overwritten from the child. This conflates two different concepts: the root company is Toprent’s record of a client (the account), while a child company is a legal entity the client uses in their own paperwork. These serve different audiences and should likely be managed independently — the root company by our support team, the child companies by the clients themselves.