You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-09-18] Crash when switching between Inbox & Spend while waiting for invited workspace chat to appear #100204
WorkspaceAvatar calls .toString() on an avatarID prop that is undefined. That throws during render, the error escapes to the root, and the whole app white-screens.
This is the confirmed throwing line, not a guess. The attached console log names main-aa1c1efc2b45656b.bundle.js:2:764701; staging still serves that exact build, and UTF-16 column 764701 in it lands on the toString token of getDefaultWorkspaceAvatarColor(y.toString()) inside the WorkspaceAvatar module, where y is the destructured avatarID prop. The stack (processRootScheduleInMicrotask → performSyncWorkOnRoot → renderRootSync → renderWithHooks) confirms it throws in the component body during a sync render, and the "navigation object hasn't been initialized yet" line right after is the tree tearing down.
Why avatarID is undefined: the only unguarded <WorkspaceAvatar> call site in the whole shipped bundle is the workspaces list row, which passes the policy ID straight through — WorkspaceTableRow.tsx:133 and :178. Every other call site coalesces with CONST.DEFAULT_NUMBER_ID.
item.policyID is just policy.id (WorkspacesListPage.tsx:146, selectors/Policy.ts:135). Rows are admitted by shouldShowPolicy, which checks type, pendingAction and role but never checks policy.id — unlike getActivePolicies, which does require !!policy.id. So the partially-populated policy_<id> record the invitee receives during the invite still produces a row, with policyID: undefined.
Why only a brand-new workspace: the crashing line is only reached on the fallback-icon branch. A workspace with an uploaded avatar has a string source and returns early at line 40. A just-joined workspace has no avatarURL, so icon is undefined and line 58 runs.
Switched WorkspaceTableRow from <Avatar> (which defaulted avatarID to CONST.DEFAULT_NUMBER_ID) to <WorkspaceAvatar> directly, dropping the last default
What changes do you think we should make in order to solve the problem?
Restore the guard in WorkspaceAvatar — make avatarID optional and coalesce before .toString() (back to the pre-[No QA] Avatar component decomposition #95050 behaviour). This alone makes the crash impossible for every caller.
Guard the call site — in WorkspaceTableRow.tsx at :133 and :178, fall back to CONST.DEFAULT_NUMBER_ID so it matches every other <WorkspaceAvatar> usage.
Optional hardening — require !!policy.id in shouldShowPolicy (or in createWorkspaceListPoliciesSelector) so an id-less policy never reaches the workspaces list at all.
What alternative solutions did you explore?
Paths ruled out, and the one assumption I could not verify
Ruled out. I searched the LHN and Spend paths first, since the report attributes this to the LHN. Neither contains the throwing line: src/components/LHNOptionsList/**, SidebarUtils.ts, useSidebarOrderedReports, and the LHN avatar chain (OptionRow/Avatar → SubscriptAvatar/SingleAvatar → AvatarFromIcon.tsx:26) all coalesce icon.id. In the Spend path, NavigationTabBar has zero .toString() calls and the five in SearchUIUtils.ts are all guarded. The bundle offset independently excludes all of them — the nearest other .toString() in the deployed bundle is ~263 KB away.
Reachability.WorkspacesListPage is a bottom-tab screen (TabNavigator.tsx) with lazy: true, freezeOnBlur: true. On web freezeOnBlur is a no-op — that is exactly why App added its own FreezeWrapper using react-freeze. ReportsSplitNavigator and SearchFullscreenNavigator are wrapped in it; WorkspaceNavigator is not. So once the Workspaces tab has been opened, it stays mounted and keeps re-rendering on policy_ Onyx updates while the user is on Inbox or Spend. The rapid tab switching supplies the sync-lane renders that make the partially-populated policy visible.
Unverified assumption. This requires the tester to have opened the Workspaces tab at some point in that session — the repro steps don't say, and it's the one link I couldn't prove. Similarly, "policy.id is briefly absent on the invitee's record" is inferred from shouldShowPolicy omitting the check (and from the ~14 !policy?.id guards elsewhere in src/libs/), not from a runtime Onyx dump. Adding a temporary console.trace in WorkspaceAvatar when avatarID == null and re-running the Applause repro would nail both in one shot. Neither affects the fix: fix 1 is correct regardless of which caller passes undefined.
Also worth a separate look:SearchQueryUtils.ts:520 does getPersonalDetailByEmail(x)?.accountID.toString() — the optional chain stops one level early. Same latent hazard, not this crash.
💡 Suggested AI code review rule
This is a recurring, mechanically detectable pattern, so it may be worth a coding-standards rule so the AI reviewer catches the next one. Proposed for Expensify/App:
Rule:CONSISTENCY-19 — Onyx record fields are possibly undefined, whatever the type says
Condition: Flag when a value read off an Onyx record (or a selector projection of one) has a method called on it — .toString(), .split(), .length — or is passed to a required prop, without ?. or a ?? fallback. Also flag a refactor that removes an existing ?./?? guard purely because the prop type became non-optional. Onyx types describe the fully-hydrated record; partial merges land field-by-field.
Why: Onyx types are aspirational, not runtime contracts. policy.id is typed string but ~14 sites in src/libs/ already guard !policy?.id. Dropping one such guard white-screened the app — this issue.
Search pattern: diffs that delete ?. or ?? CONST.DEFAULT_NUMBER_ID from a line while keeping the call; and \.(toString|split|trim|toLowerCase)\( applied directly to policy\.id, report\.reportID, or \.accountID without ?..
The full rule file, with the ❌/✅ code inline in App's coding-standards format, would go in App/.claude/skills/coding-standards/rules/. If it's worth adding, a maintainer can open it there as a draft PR.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/100204) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
Almost certainly the same issue — but I couldn't open the Sentry link to confirm it myself. The Sentry MCP server needs an interactive OAuth login and didn't authenticate in this run, so I can't read issue 7684111007. Here's everything you need to decide it in about ten seconds.
(Both your links point at the same issue ID — the second just adds a user.email filter — so it's one Sentry issue, not two.)
This crash definitely does reach Sentry
The throw happens during render, so React unwinds to App's root error boundary at App.tsx:135, which calls logError.ts:10 → Sentry.captureException. A Sentry issue for this crash must exist.
TypeError: Cannot read properties of undefined (reading 'toString')
at main-aa1c1efc2b45656b.bundle.js:2:764701
at renderWithHooks
at updateFunctionComponent
at beginWork
...
at performSyncWorkOnRoot
at processRootScheduleInMicrotask
It's the same issue if all three hold:
Title is TypeError: Cannot read properties of undefined (reading 'toString').
The top in-app frame is WorkspaceAvatar — WorkspaceAvatar.tsx:58, getDefaultWorkspaceAvatarColor(avatarID.toString()).
The event carries the errorInfo extra and the NewExpensify crash caught by error boundary message, i.e. it came through the error boundary rather than a raw handler.
Check 2 is the one that matters. Cannot read properties of undefined (reading 'toString') is a generic message and Sentry groups on stack — if the top in-app frame is anything other than WorkspaceAvatar, it's a different bug that happens to share a message, and the sameness doesn't follow from the title alone.
Your second link is already good supporting evidence: it shows 7684111007 has events from jsoidjnosnjionsjdosjo2@gmail.com, the exact Applause tester on this report.
Still unfixed on main
Both parts of the proposal are unchanged as of ce33920: WorkspaceAvatar.tsx:58 still calls .toString() unguarded on a required avatarID prop, and WorkspaceTableRow.tsx:133 and :178 still pass item.policyID straight through with no CONST.DEFAULT_NUMBER_ID fallback.
If 7684111007 does point at WorkspaceAvatar, its event volume also settles the open question from my proposal — how often an id-less policy actually reaches that row — and the ?environment= breakdown would tell us whether it's staging-only or hitting production users too. Worth pasting the top frames here either way.
That's the same Sentry issue as your first link — ID 7684111007, just filtered to the tester's email across staging and production — so my answer above is unchanged, and I still couldn't open it. Sentry needs an interactive OAuth login that isn't available to me here.
The one check that settles it: in that filtered view, open any event and look at the top in-app frame. If it's WorkspaceAvatar.tsx:58 (getDefaultWorkspaceAvatarColor(avatarID.toString())), it's this bug. The title alone won't tell you — Cannot read properties of undefined (reading 'toString') is generic and Sentry groups on stack.
Since you've already scoped it to this tester, two things in that view are worth pasting back: the event count (how often an id-less policy actually reaches that row — the open question in my proposal) and the staging-vs-production split (whether real users are hitting it, not just Applause).
Activity
applause-bot commentedon Sep 2, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/59dcb2e5da817ace21adfe8fb23438bdb80bfedd380a51f4debcdf16e649f087
https://platform.applause.com/services/links/v1/external/6fc62dea887aff47f7388f225151dc95577a4eadb4216b23b11729bcf1552802
MelvinBot commentedon Sep 2, 2026
Proposal
What is the root cause of that problem?
WorkspaceAvatarcalls.toString()on anavatarIDprop that isundefined. That throws during render, the error escapes to the root, and the whole app white-screens.src/components/Avatar/WorkspaceAvatar.tsx:58This is the confirmed throwing line, not a guess. The attached console log names
main-aa1c1efc2b45656b.bundle.js:2:764701; staging still serves that exact build, and UTF-16 column 764701 in it lands on thetoStringtoken ofgetDefaultWorkspaceAvatarColor(y.toString())inside theWorkspaceAvatarmodule, whereyis the destructuredavatarIDprop. The stack (processRootScheduleInMicrotask → performSyncWorkOnRoot → renderRootSync → renderWithHooks) confirms it throws in the component body during a sync render, and the "navigation object hasn't been initialized yet" line right after is the tree tearing down.Why
avatarIDis undefined: the only unguarded<WorkspaceAvatar>call site in the whole shipped bundle is the workspaces list row, which passes the policy ID straight through —WorkspaceTableRow.tsx:133and:178. Every other call site coalesces withCONST.DEFAULT_NUMBER_ID.item.policyIDis justpolicy.id(WorkspacesListPage.tsx:146,selectors/Policy.ts:135). Rows are admitted byshouldShowPolicy, which checks type, pendingAction and role but never checkspolicy.id— unlikegetActivePolicies, which does require!!policy.id. So the partially-populatedpolicy_<id>record the invitee receives during the invite still produces a row, withpolicyID: undefined.Why only a brand-new workspace: the crashing line is only reached on the fallback-icon branch. A workspace with an uploaded avatar has a string
sourceand returns early at line 40. A just-joined workspace has noavatarURL, soiconis undefined and line 58 runs.Regression history:
getDefaultWorkspaceAvatarColor(avatarID?.toString() ?? '')to the unguarded form and madeavatarIDa required propWorkspaceTableRowfrom<Avatar>(which defaultedavatarIDtoCONST.DEFAULT_NUMBER_ID) to<WorkspaceAvatar>directly, dropping the last defaultWhat changes do you think we should make in order to solve the problem?
WorkspaceAvatar— makeavatarIDoptional and coalesce before.toString()(back to the pre-[No QA] Avatar component decomposition #95050 behaviour). This alone makes the crash impossible for every caller.WorkspaceTableRow.tsxat :133 and :178, fall back toCONST.DEFAULT_NUMBER_IDso it matches every other<WorkspaceAvatar>usage.!!policy.idinshouldShowPolicy(or increateWorkspaceListPoliciesSelector) so an id-less policy never reaches the workspaces list at all.What alternative solutions did you explore?
Paths ruled out, and the one assumption I could not verify
Ruled out. I searched the LHN and Spend paths first, since the report attributes this to the LHN. Neither contains the throwing line:
src/components/LHNOptionsList/**,SidebarUtils.ts,useSidebarOrderedReports, and the LHN avatar chain (OptionRow/Avatar→SubscriptAvatar/SingleAvatar→AvatarFromIcon.tsx:26) all coalesceicon.id. In the Spend path,NavigationTabBarhas zero.toString()calls and the five inSearchUIUtils.tsare all guarded. The bundle offset independently excludes all of them — the nearest other.toString()in the deployed bundle is ~263 KB away.Reachability.
WorkspacesListPageis a bottom-tab screen (TabNavigator.tsx) withlazy: true, freezeOnBlur: true. On webfreezeOnBluris a no-op — that is exactly why App added its ownFreezeWrapperusingreact-freeze.ReportsSplitNavigatorandSearchFullscreenNavigatorare wrapped in it;WorkspaceNavigatoris not. So once the Workspaces tab has been opened, it stays mounted and keeps re-rendering onpolicy_Onyx updates while the user is on Inbox or Spend. The rapid tab switching supplies the sync-lane renders that make the partially-populated policy visible.Unverified assumption. This requires the tester to have opened the Workspaces tab at some point in that session — the repro steps don't say, and it's the one link I couldn't prove. Similarly, "
policy.idis briefly absent on the invitee's record" is inferred fromshouldShowPolicyomitting the check (and from the ~14!policy?.idguards elsewhere insrc/libs/), not from a runtime Onyx dump. Adding a temporaryconsole.traceinWorkspaceAvatarwhenavatarID == nulland re-running the Applause repro would nail both in one shot. Neither affects the fix: fix 1 is correct regardless of which caller passesundefined.Also worth a separate look:
SearchQueryUtils.ts:520doesgetPersonalDetailByEmail(x)?.accountID.toString()— the optional chain stops one level early. Same latent hazard, not this crash.💡 Suggested AI code review rule
This is a recurring, mechanically detectable pattern, so it may be worth a coding-standards rule so the AI reviewer catches the next one. Proposed for
Expensify/App:CONSISTENCY-19— Onyx record fields are possibly undefined, whatever the type says.toString(),.split(),.length— or is passed to a required prop, without?.or a??fallback. Also flag a refactor that removes an existing?./??guard purely because the prop type became non-optional. Onyx types describe the fully-hydrated record; partial merges land field-by-field.policy.idis typedstringbut ~14 sites insrc/libs/already guard!policy?.id. Dropping one such guard white-screened the app — this issue.?.or?? CONST.DEFAULT_NUMBER_IDfrom a line while keeping the call; and\.(toString|split|trim|toLowerCase)\(applied directly topolicy\.id,report\.reportID, or\.accountIDwithout?..WorkspaceAvatar.tsx:58andWorkspaceTableRow.tsx:133AvatarFromIcon.tsx:26The full rule file, with the ❌/✅ code inline in App's coding-standards format, would go in
App/.claude/skills/coding-standards/rules/. If it's worth adding, a maintainer can open it there as a draft PR.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/100204)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run · no recording available
melvin-bot commentedon Sep 2, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @linhvovan29546 (
External)melvin-bot commentedon Sep 2, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
linhvovan29546 commentedon Sep 3, 2026
@MelvinBot The crash looks related to this Sentry issue. Could you please check if it’s the same issue? https://expensify.sentry.io/issues/7684111007/
linhvovan29546 commentedon Sep 3, 2026
@MelvinBot And this one as well https://expensify.sentry.io/issues/7684111007/?environment=staging&environment=production&project=4510228107427840&query=user.email%3A%EF%80%8DContains%EF%80%8Djsoidjnosnjionsjdosjo2%40gmail.com&referrer=issue-stream&sort=freq
MelvinBot commentedon Sep 3, 2026
Almost certainly the same issue — but I couldn't open the Sentry link to confirm it myself. The Sentry MCP server needs an interactive OAuth login and didn't authenticate in this run, so I can't read issue 7684111007. Here's everything you need to decide it in about ten seconds.
(Both your links point at the same issue ID — the second just adds a
user.emailfilter — so it's one Sentry issue, not two.)This crash definitely does reach Sentry
The throw happens during render, so React unwinds to App's root error boundary at
App.tsx:135, which callslogError.ts:10→Sentry.captureException. A Sentry issue for this crash must exist.Fingerprint to match against 7684111007
From the attached Applause console log:
It's the same issue if all three hold:
TypeError: Cannot read properties of undefined (reading 'toString').WorkspaceAvatar—WorkspaceAvatar.tsx:58,getDefaultWorkspaceAvatarColor(avatarID.toString()).errorInfoextra and theNewExpensify crash caught by error boundarymessage, i.e. it came through the error boundary rather than a raw handler.Check 2 is the one that matters.
Cannot read properties of undefined (reading 'toString')is a generic message and Sentry groups on stack — if the top in-app frame is anything other thanWorkspaceAvatar, it's a different bug that happens to share a message, and the sameness doesn't follow from the title alone.Your second link is already good supporting evidence: it shows 7684111007 has events from jsoidjnosnjionsjdosjo2@gmail.com, the exact Applause tester on this report.
Still unfixed on main
Both parts of the proposal are unchanged as of
ce33920:WorkspaceAvatar.tsx:58still calls.toString()unguarded on a requiredavatarIDprop, andWorkspaceTableRow.tsx:133and:178still passitem.policyIDstraight through with noCONST.DEFAULT_NUMBER_IDfallback.If 7684111007 does point at
WorkspaceAvatar, its event volume also settles the open question from my proposal — how often an id-less policy actually reaches that row — and the?environment=breakdown would tell us whether it's staging-only or hitting production users too. Worth pasting the top frames here either way.view run
MelvinBot commentedon Sep 3, 2026
That's the same Sentry issue as your first link — ID
7684111007, just filtered to the tester's email across staging and production — so my answer above is unchanged, and I still couldn't open it. Sentry needs an interactive OAuth login that isn't available to me here.The one check that settles it: in that filtered view, open any event and look at the top in-app frame. If it's
WorkspaceAvatar.tsx:58(getDefaultWorkspaceAvatarColor(avatarID.toString())), it's this bug. The title alone won't tell you —Cannot read properties of undefined (reading 'toString')is generic and Sentry groups on stack.Since you've already scoped it to this tester, two things in that view are worth pasting back: the event count (how often an id-less policy actually reaches that row — the open question in my proposal) and the staging-vs-production split (whether real users are hitting it, not just Applause).
view run
linhvovan29546 commentedon Sep 3, 2026
MelvinBot's proposal LGTM!
🎀 👀 🎀 C+ reviewed
16 remaining items
melvin-bot commentedon Sep 17, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Sep 17, 2026
Payment Summary
Resolving PRs:
Fix crash when a workspace avatar renders before its policy ID lands #100539
Reviewer: @linhvovan29546 owed $250 via NewDot
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Sep 22, 2026
Payment Summary
Contributor+: @linhvovan29546 due $250 via NewDot
twisterdotcom commentedon Sep 25, 2026
$250 approved for @linhvovan29546 in Report ID: R00MQdU7mGci.
Zapier Logs
Run ID: 00040eee-d084-aa06-a2e1-04be78c3bab4SO: https://stackoverflowteams.com/c/expensify/questions/7582