Skip to content

[Due for payment 2026-06-25] [$250] [Sentry: APP-DTS] Web – Crash for Chrome 103 / Chrome OS users: Array.toReversed is not a function in MoneyRequestReportActionsList #91964

Closed

Description

@mountiny

If you haven't already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.82-3
Reproducible in staging?: Yes
Reproducible in production?: Yes
Issue reported by: Internal Sentry investigation
Sentry: https://expensify.sentry.io/issues/APP-DTS

Action Performed

  1. Open any expense report in Search (route: /search)
  2. View on Chrome 103 or an older Chromium-based browser (e.g. a managed Chrome OS device that hasn't updated past Chrome 110)

Expected Result

Expense report renders normally.

Actual Result

Full-page "Uh-oh, something went wrong!" ErrorBoundary crash screen. The app is completely unusable until the page is refreshed.

Workaround

Update Chrome / Chrome OS to a version that supports Array.prototype.toReversed() (Chrome 110+).

Platforms

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Technical details

Array.prototype.toReversed() was added in Chrome 110 / Safari 16.4. Users on Chrome 103 (common in managed/enterprise Chrome OS environments that enforce a slower update cadence) don't have this method, so the call throws a TypeError during render which is caught by the ErrorBoundary.

Source: src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx:173

// Current (crashes on Chrome < 110):
return filteredActions.toReversed();

// Fix:
return filteredActions.slice().reverse();

Sentry stack: MoneyRequestReportActionsList → useMemo (visibleReportActions) → filteredActions.toReversed() → TypeError → ErrorBoundary.

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 28, 2026
  2. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on May 28, 2026
  3. melvin-bot commented on May 28, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @eh2077 (External)

  4. melvin-bot commented on May 28, 2026

    @melvin-bot
  5. yusufdeveloper2903 commented on May 28, 2026

    @yusufdeveloper2903
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-05-28 16:14:48 UTC.

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On Chrome 103 / older Chromium (managed Chrome OS that hasn't updated past Chrome ~110), opening an expense report from /search throws TypeError: filteredActions.toReversed is not a function during render. The ErrorBoundary catches it and the user gets the full-page "Uh-oh, something went wrong!" crash until they refresh.

    What is the root cause of that problem?

    Array.prototype.toReversed() is part of the ES2023 "Change Array by Copy" group (Chrome 110 / Safari 16.4). On Chrome 103 the method is undefined, so the call at MoneyRequestReportActionsList.tsx#L176 throws synchronously inside the visibleReportActions useMemo → render fails → ErrorBoundary.

    The deeper cause is a missing polyfill, not a single bad call. The app already supports these old browsers and already handles this exact incompatibility class:

    • src/setup/index.ts#L19 runs toSortedPolyfill.shim() (added in commit 3c18f5fac7e7f) — setup/index.ts is the designated polyfill home, also running intlPolyfill().
    • That shim exists specifically because AnnouncementSection.tsx#L11 calls .toSorted() — the sibling ES2023 method.

    So .toSorted() is safe on Chrome 103, but .toReversed() (introduced later via PR #90680) was never given a matching shim. The two members of the same feature group were handled inconsistently — toReversed is the gap.

    What changes do you think we should make in order to solve the problem?

    Add the toReversed shim right next to the existing toSorted shim, mirroring the established pattern exactly (same es-shims family, same author).

    1. package.json — add the dependency alongside the existing "array.prototype.tosorted":

    "array.prototype.toreversed": "^1.1.2",

    2. src/setup/index.ts — import and shim it next to toSorted:

    import toReversedPolyfill from 'array.prototype.toreversed';
    import toSortedPolyfill from 'array.prototype.tosorted';
    // ...
        toSortedPolyfill.shim();
        toReversedPolyfill.shim();

    3. src/types/modules/array.prototype.toreversed.d.ts (new) — mirror array.prototype.tosorted.d.ts:

    declare module 'array.prototype.toreversed' {
        function getPolyfill(): typeof Array.prototype.toReversed;
        function shim(): typeof Array.prototype.toReversed;
        function implementation<T>(): T[];
    
        export {getPolyfill, shim, implementation};
    }
    • No change at the call site — MoneyRequestReportActionsList.tsx#L176 keeps .toReversed() and is fixed globally, along with any future .toReversed() use.
    • Files touched: package.json, package-lock.json, src/setup/index.ts, src/types/modules/array.prototype.toreversed.d.ts.
    • Platforms: web/desktop. shim() only patches when the native method is absent, so it's a no-op on modern Chrome/Safari and on native (Hermes already has toReversed) — zero behavior change there.

    Test plan

    • Chrome 103 (or run delete Array.prototype.toReversed in the console before load): open an expense report from /search → renders normally, no ErrorBoundary.
    • Confirm report actions still render newest-first (ordering preserved).
    • Modern Chrome: open the same report → no regression (shim is a no-op).

    What alternative solutions did you explore? (Optional)

    • filteredActions.slice().reverse() at the call site (the issue's suggestion) — valid and dependency-free, but rejected because it patches only this one call site and diverges from the established toSorted shim convention; the next .toReversed() / .toSpliced() / .with() added anywhere would reintroduce the same Chrome 103 crash. The polyfill fixes the whole class at the boundary.
    • Broaden @babel/preset-env targets / add core-js to transpile-polyfill ES2023 globally — rejected: far larger blast radius and bundle cost for one missing method; the targeted es-shim matches the team's existing approach.
    • Add an ESLint rule banning .toReversed() — rejected: doesn't fix the existing crash by itself and fights the polyfill pattern already adopted for toSorted.
  6. github-actions commented on May 28, 2026

    @github-actions
    Contributor

    ⚠️ @yusufdeveloper2903 Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

  7. aswin-s commented on May 28, 2026

    @aswin-s
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a user on Chrome/Chromium < 110 (or Safari < 16.4) — common on managed Chrome OS devices with a slow update cadence — opens an expense report in Search on Web, the app renders the full-page "Uh-oh, something went wrong!" ErrorBoundary crash and becomes unusable until refresh. Expected: the expense report renders normally regardless of browser version.

    What is the root cause of that problem?

    src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx:176 calls filteredActions.toReversed() inside the visibleReportActions useMemo. Array.prototype.toReversed() is an ES2023 method shipped only in Chrome 110 / Safari 16.4; on older engines it is undefined, so the call throws TypeError: ...toReversed is not a function during render, which the top-level ErrorBoundary catches and replaces with the crash screen. This is the only toReversed usage in src/.

    What changes do you think we should make in order to solve the problem?

    1. In src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx:176, replace return filteredActions.toReversed(); with return filteredActions.slice().reverse(); — produces the same new (non-mutating) reversed array, but uses only methods supported in every targeted browser.
    2. No sibling/platform twins exist: grep confirms toReversed appears exactly once across src/, and this component has no .web/.native variants for this logic. The nearby visibleReportActions.at(-1) (line 192) and findLastIndex (line 399) are safe — both are supported since Chrome 92 / Safari 15.4, well below the failing versions.

    What alternative solutions did you explore? (Optional)

    Add a global Array.prototype.toReversed polyfill, but that broadens scope beyond this crash and a local non-mutating slice().reverse() is simpler and matches the existing call's semantics.

  8. wildan-m commented on May 28, 2026

    @wildan-m
    Contributor

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  9. trasnake87 commented on May 28, 2026

    @trasnake87
    Contributor

    Proposal

    Chrome 103 and other Chromium-based browsers below 110 (still common in managed Chrome OS fleets) crash with TypeError: filteredActions.toReversed is not a function the moment they enter an expense report from /search, because the web bundle ships an un-transpiled Array.prototype.toReversed() call to a runtime that does not implement it.

    Root cause

    The crash is thrown from this useMemo body inside MoneyRequestReportActionsList.tsx:

    // src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx:151-177
    // We are reversing actions because in this View we are starting at the top and don't use Inverted list
    const visibleReportActions = useMemo(() => {
        const filteredActions = reportActions.filter((reportAction) => {
            // ...visibility / offline / IOU filters...
            return true;
        });
    
        return filteredActions.toReversed();
    }, [reportActions, isOffline, canPerformWriteAction, reportTransactionIDs, shouldShowHarvestCreatedAction, visibleReportActionsData, reportID]);

    Array.prototype.toReversed() is an ES2023 method that shipped in Chrome 110 / Safari 16.4 / Firefox 115. On Chrome 103 the method is undefined, so the invocation throws TypeError: filteredActions.toReversed is not a function inside the render-phase useMemo. React surfaces that into the nearest ErrorBoundary, producing the full-page "Uh-oh, something went wrong!" screen reported in Sentry (issue APP-DTS).

    The reason this reaches users at all is the build configuration. babel.config.js:29 declares:

    const defaultPresetsForWebpack = ['@babel/preset-react', ['@babel/preset-env', {targets: {node: 20}}], '@babel/preset-flow', '@babel/preset-typescript'];

    @babel/preset-env is targeted at Node 20, which natively supports toReversed(), so the preset emits no down-level transform for the call. There is no core-js / useBuiltIns polyfill chain in the web bundle either, so the method must exist on the runtime engine. For any browser older than Chrome 110 the call is therefore a hard crash. Re-targeting the browser baseline is out of scope for a single bounty (the rest of the app would need to be re-validated), so the correct fix is to stop relying on the ES2023 immutable-copy methods in source.

    There is exactly one other production call site of the same ES2023 family — Array.prototype.toSorted() — which is also unsafe on Chrome 103 and worth patching in the same change:

    // src/pages/home/AnnouncementSection.tsx:11-19
    const announcements = CONST.HOME.ANNOUNCEMENTS.toSorted((a, b) => {
        if (a.publishedDate > b.publishedDate) {
            return -1;
        }
        if (a.publishedDate < b.publishedDate) {
            return 1;
        }
        return 0;
    });

    This one runs at module-evaluation time on a non-empty array (see src/CONST/index.ts:10104+), so any Chrome 103 user who loads a chunk that imports AnnouncementSection will hit the same TypeError before the component even mounts. Confirmed by grepping the src/ tree — only these two production usages exist (tests/unit/* matches are Jest/Node-only and irrelevant):

    src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx:176:        return filteredActions.toReversed();
    src/pages/home/AnnouncementSection.tsx:11:const announcements = CONST.HOME.ANNOUNCEMENTS.toSorted((a, b) => {
    

    No toSpliced / Array.prototype.with calls exist in src/.

    Proposed fix

    1 - Replace toReversed() in MoneyRequestReportActionsList.tsx:

    // src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx:176
    // Before:
    return filteredActions.toReversed();
    
    // After:
    return filteredActions.slice().reverse();

    filteredActions is already a fresh array produced by Array.prototype.filter on line 153, so theoretically .reverse() alone would not mutate caller-owned state — but keeping the .slice() preserves the original immutable-copy semantics and matches the established pattern in the codebase (see precedent below), so future refactors that pass the result through additional pipelines stay safe.

    2 - Replace toSorted() in AnnouncementSection.tsx:

    // src/pages/home/AnnouncementSection.tsx:11-19
    // Before:
    const announcements = CONST.HOME.ANNOUNCEMENTS.toSorted((a, b) => {
        if (a.publishedDate > b.publishedDate) {
            return -1;
        }
        if (a.publishedDate < b.publishedDate) {
            return 1;
        }
        return 0;
    });
    
    // After:
    const announcements = [...CONST.HOME.ANNOUNCEMENTS].sort((a, b) => {
        if (a.publishedDate > b.publishedDate) {
            return -1;
        }
        if (a.publishedDate < b.publishedDate) {
            return 1;
        }
        return 0;
    });

    The spread copy is required here because CONST.HOME.ANNOUNCEMENTS is a shared static array — a bare .sort() would mutate the constant in place and produce non-deterministic order on subsequent imports.

    3 - Prevent future regressions with an ESLint rule (lightweight, optional but recommended in the same PR so a third occurrence cannot sneak in):

    // .eslintrc.js — add to the existing `rules` block
    'no-restricted-syntax': [
        'error',
        {
            selector: "CallExpression[callee.property.name=/^(toReversed|toSorted|toSpliced)$/]",
            message: 'Array.prototype.toReversed/toSorted/toSpliced require Chrome 110+. Use [...arr].reverse()/sort()/splice() instead. See issue #91964.',
        },
    ],

    (If the maintainers prefer not to extend the lint config in the same PR, the two source-level changes above are sufficient to close the bounty.)

    Why this approach

    Precedent already exists in the codebase: src/pages/inbox/report/useActiveDraftReportAction.ts:33 deliberately uses the [...ancestors].slice().reverse() pattern rather than toReversed(), so the two replacements above bring the remaining stragglers in line with established style.

    Alternatives that were considered and rejected:

    • Polyfilling via core-js would fix every call site but balloons the web bundle (core-js/es/array adds ~10 KB gzipped for methods we use exactly twice) and conflicts with the existing targets: {node: 20} posture in babel.config.js. Two one-line source edits cost nothing at runtime.
    • Bumping the @babel/preset-env target to defaults / > 0.5% would re-transpile the entire bundle and force a full QA pass on web, far outside the bounty scope, and would not have caught the AnnouncementSection module-load crash either (that one is in the same TC39 family).
    • Wrapping calls in a typeof Array.prototype.toReversed === 'function' runtime check keeps the modern API on capable browsers but adds branching at every call site for zero perf benefit, since .slice().reverse() is already an O(n) operation that V8 optimizes identically.

    The two replacements are byte-for-byte equivalent in semantics (both return a new array, leave the source untouched, and use a stable in-place reverse/sort on a freshly-allocated copy) and unblock every Chrome 103 / managed Chrome OS user without touching the build pipeline.

  10. MelvinBot commented on May 28, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    Array.prototype.toReversed() is an ES2023 method only available in Chrome 110+ / Safari 16.4+. At MoneyRequestReportActionsList.tsx:176, the visibleReportActions useMemo calls filteredActions.toReversed(). On Chrome 103 (common in managed Chrome OS environments), this throws a TypeError during render, which propagates to the ErrorBoundary and crashes the entire page.

    This is the only production call site — the other 4 usages of .toReversed() are in test files (hasNextActionMadeBySameActorTest.ts and isConsecutiveActionMadeByPreviousActorTest.ts) which run in Node/Jest and are unaffected.

    What changes do you think we should make in order to solve the problem?

    Replace filteredActions.toReversed() with filteredActions.slice().reverse() at MoneyRequestReportActionsList.tsx:176. slice() creates a shallow copy and reverse() mutates that copy in place — semantically identical to toReversed() but supported across all browsers.

    What alternative solutions did you explore? (Optional)

    A global polyfill for Array.prototype.toReversed (e.g. in src/setup/) would cover any future usages, but is unnecessary overhead for a single production call site and risks masking native implementations. The slice().reverse() pattern is the standard pre-ES2023 idiom and requires no additional dependencies.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement this to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  11. github-actions commented on May 28, 2026

    @github-actions
    Contributor

    ⚠️ @wildan-m Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  12. 57 remaining items

  13. melvin-bot commented on Jun 24, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  14. melvin-bot commented on Jun 24, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    • Reviewer: @eh2077 owed $250 via NewDot

    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/2059992251751906051/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
  15. eh2077 commented on Jun 25, 2026

    @eh2077
    Contributor

    @mallenexpensify checklist is here #91964 (comment), thx!

  16. mallenexpensify commented on Jun 27, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @eh2077 due $250 via NewDot

  17. laurenreidexpensify commented on Aug 4, 2026

    @laurenreidexpensify
    Contributor

    $250 approved @eh2077

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.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions