Skip to content

[Due for payment 2026-07-16] [Sentry: APP-H08] Crash toggling Sage Intacct default vendor when vendors list is empty #95342

Closed

Description

@mountiny

Sentry

https://expensify.sentry.io/issues/APP-H08

Impact (snapshot at filing)

  • Users (total since first seen): 1
  • Events: 3
  • Users (last 14d): 1
  • First seen: 2026-07-03
  • Last seen: 2026-07-03 (ongoing)
  • Platform: web
  • App version(s): 9.4.25-2
  • Affected route(s) (parameterized): /workspaces/:policyID/accounting/sage-intacct/export/reimbursable
  • Mechanism: auto.browser.browserapierrors.requestAnimationFrame

Stack trace (top frames, first-party only)

Switch.tsx:75 (<anonymous>) → onToggle(!isOn)
ToggleSettingsOptionRow.tsx:240 (t16) → onToggle(isOn)
SageIntacctReimbursableExpensesPage.tsx:83 (menuItems.onToggle) → vendors?.[0].id

Suspected cause

Optional chaining stops at vendors?.[0]; when the vendors array is empty, [0] is undefined and accessing .id throws. Same pattern exists on the non-reimbursable export page.

Reproduction

  1. Connect a workspace to Sage Intacct with an empty vendors list (or before vendors sync completes).
  2. Navigate to Accounting → Sage Intacct → Export → Reimbursable expenses.
  3. Toggle "Default vendor" ON.
  4. Observe TypeError in console: Cannot read properties of undefined (reading 'id').

Related

  • Sibling Sentry IDs (if any): none
  • Prior GH issues: none
  • Fix PR: pending
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    ReviewingHas a PR in review
    and removed on Jul 5, 2026
  2. mountiny commented on Jul 5, 2026

    @mountiny
    ContributorAuthor

    Fix PR: #95345

  3. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 6, 2026
  4. MelvinBot commented on Jul 6, 2026

    @MelvinBot
    Contributor

    Issue Analysis

    Root Cause: Optional chaining stops one level too early. In both Sage Intacct export pages the default-vendor toggle reads vendors?.[0].id — the ?. guards vendors being nullish, but not the array being empty. When the synced vendors list is [], vendors?.[0] is undefined and .id throws Cannot read properties of undefined (reading 'id'), matching the Sentry crash on the onToggle path.

    Recommended Fix: Add optional chaining before .id → vendors?.[0]?.id. The result is already coalesced with ?? '' at the call site, so an empty list safely produces ''.

    ✅ This is exactly what PR #95345 does — it changes vendors?.[0].id → vendors?.[0]?.id on both pages and nothing else. The fix is correct and complete for the reported crash.

    Investigation details

    Symptom → mechanism → confirmation

    • Stack trace bottoms out at SageIntacctReimbursableExpensesPage.tsx menuItems.onToggle → vendors?.[0].id, bubbling up through ToggleSettingsOptionRow and Switch. Verified the toggle callback is the only place vendors?.[0].id is dereferenced.
    • enabled ? …vendors?.[0].id : '' — the crash only fires when toggling ON with an empty/unsynced vendors array, which lines up with the reproduction steps (empty vendors list / before sync completes) and the low event count (needs a Sage Intacct workspace in that transient state).

    Alternative explanations considered & ruled out

    • Not a nullish vendors (that branch is already guarded by ?.) — the failure requires vendors to be a non-null but empty array.
    • Not a policy/connections/data issue — those are all guarded by the same optional-chaining chain; only the [0] index access is unguarded.

    Scope check: The pattern appears on both the reimbursable and non-reimbursable pages, and PR #95345 patches both — matching the "same pattern exists on the non-reimbursable export page" note in the issue. No other vendors?.[0].id occurrences exist in the codebase.

    Confidence: High — code evidence matches the Sentry stack trace exactly, the failure condition is reproducible from the code path, and the existing fix targets precisely the faulty expression.


    The open fix PR already implements this correctly, so no further code change is needed — this analysis just confirms the root cause and validates the fix.

  5. added and removed
    ReviewingHas a PR in review
    on Jul 9, 2026
  6. changed the title [-][Sentry: APP-H08] Crash toggling Sage Intacct default vendor when vendors list is empty[/-] [+][Due for payment 2026-07-16] [Sentry: APP-H08] Crash toggling Sage Intacct default vendor when vendors list is empty[/+] on Jul 9, 2026
  7. 8 remaining items

  8. QichenZhu commented on Jul 10, 2026

    @QichenZhu
    Contributor

    No new Sentry records since the fix went to staging. I believe the crash is resolved.

    I'll be OOO from the 13th to 29th of July 2026. If this issue needs attention during that time, please reassign it.

  9. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Jul 15, 2026
  10. melvin-bot commented on Jul 15, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  11. melvin-bot commented on Jul 15, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  12. mallenexpensify commented on Jul 17, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @QichenZhu due $250 via NewDot

    ^ Test case created. Thx

  13. trjExpensify commented on Aug 3, 2026

    @trjExpensify
    Contributor

    approved $250 for @QichenZhu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions