App icon indicating copy to clipboard operation
App copied to clipboard

[$250] Chat view - Clicking nothing for now shows an error when screen size is small

Open applause-bot[bot] opened this issue 4 months ago β€’ 28 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.4.32-0 Reproducible in staging?: Yes Reproducible in production?: No If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/63957099/folder/13176877/41237359/1554721739 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Windows 11 / Chrome App Component: Other

Action Performed:

Precondition : Resize the browser to atleast half of the sceen

  1. Open staging.new.expensify
  2. Go to own chat
  3. Submit an expense
  4. Click on nothing for now

Expected Result:

It should not show any error

Actual Result:

Error appears when click on nothing for now when screen size is small

Workaround:

Unknown

Platforms:

  • [ ] Android: App
  • [ ] Android: mWeb Chrome
  • [ ] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/b1595848-8797-458f-ad76-5b5d28f35378

View all open jobs on GitHub

Applause Internal Information Exported by: Svetlana Lazutkina Bug ID: 7203839

Upwork Automation - Do Not Edit

applause-bot[bot] avatar Jul 09 '26 15:07 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/806e6dea0f9fff4cd0d878956f3be4ded356367a5624ce63cb258c4587fc5482

applause-bot[bot] avatar Jul 09 '26 15:07 applause-bot[bot]

Triggered auto assignment to @NicolasBonet (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

melvin-bot[bot] avatar Jul 09 '26 15:07 melvin-bot[bot]

πŸ’¬ A slack conversation has been started in #expensify-open-source

melvin-bot[bot] avatar Jul 09 '26 15:07 melvin-bot[bot]

:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

github-actions[bot] avatar Jul 09 '26 15:07 github-actions[bot]

⚠️ Preliminary analysis (low confidence) β€” I could not capture the exact error or reproduce the crash, so treat this as a starting point, not a conclusion.

What "Nothing for now" does: It is the only track-expense whisper button whose onPress calls dismissTrackExpenseActionableWhisper (the other three navigate to the participant selector). That function is layout-agnostic β€” it just optimistically merges resolution: 'nothing' onto the report action and fires the API write (Report/index.ts:6001). Once resolved, the whole whisper action is hidden by shouldReportActionBeVisible.

So the error is almost certainly not in the dismiss call itself, but in the re-render/list re-computation triggered when the whisper disappears β€” and it only surfaces on a small/narrow layout. I could not find a narrow-layout-gated throw statically, and a correct click on the button did not crash on latest main (see below), so I can't confirm the mechanism.

To move this forward, the single most useful thing is the exact red-box/console error + stack frame from the repro video (e.g. Cannot read properties of undefined (reading …) and the component name). That will immediately point to the throwing component. This is a client-side JS error, so it won't be in server logs.

Investigation details
  • Confirmed: dismissTrackExpenseActionableWhisper has no responsive-layout dependency; after it resolves the whisper, the action is removed from the list. The only narrow-layout branch in the direct render path is isEditingInline in ChatMessageContent, which does not touch track-expense whispers.
  • Could not reproduce on main (HEAD 5fadbf3): In a narrow (~800px) browser, submitting a self-DM expense and clicking "Nothing for now" fired DismissActionableWhisper (HTTP 200) and dismissed the whisper with no visible error. (The test tooling did misfire one click onto the emoji picker, but that is an accessibility-ref artifact, not the reported bug.) This build is newer than the reported staging build 9.4.32-0, so the offending change may already be reverted/fixed, or the crash needs specific state (e.g. the track-flows beta, which enables the extra "Categorize"/"Share" options) not present in the test account.
  • Best candidates for the throw, if it is a re-render crash gated on narrow layout: a sibling consumer of the same action that recomputes when it disappears β€” e.g. OptionRowLHNData.tsx:106 (reads getOriginalMessage(lastAction)?.transactionID for the resolved whisper) or the tracked-expense preview/thread-divider recompute in ReportActionsList.

Suggested next steps for the assignee:

  1. Grab the exact console error + stack from the repro video / a fresh repro with DevTools open.
  2. Confirm whether it still reproduces on the latest staging build β€” I could not reproduce a crash on current main.
  3. If it reproduces, the offending PR is likely one in this deploy that touches the track-expense whisper render path or a component that re-renders when the whisper resolves.

Next Steps: Reply with @MelvinBot <the exact error text from the video> and I'll pinpoint the throwing component, or @MelvinBot <your feedback> to refine this analysis.

MelvinBot avatar Jul 09 '26 15:07 MelvinBot

I tried to reproduce this and got nothing:

https://github.com/user-attachments/assets/ff3b4370-a2f8-4320-aef8-c0c42d15582e

Please try to reproduce it again. Asking for a re-test.

NicolasBonet avatar Jul 09 '26 17:07 NicolasBonet

Able to reproduce in latest staging. Reproduction steps:

  1. Open staging.new.expensify
  2. Go to own chat
  3. Submit an expense
  4. Click on nothing for now
  5. Then reduce the window size.

https://github.com/user-attachments/assets/7375c7f1-f4c0-48f4-8a1c-3e8f1fcc224a

m-natarajan avatar Jul 09 '26 17:07 m-natarajan

@MelvinBot please assign someone else, I have two other blockers, I cannot take care of this one which is unrelated with my changes.

NicolasBonet avatar Jul 09 '26 18:07 NicolasBonet

πŸ” Investigation Summary

Classification: Frontend bug Causing PR: #95045 - "Open linked message at top - 3" by @VickyStash (Medium-High confidence) Related Issues: None

Recommendation: REVERT

This PR reworked the report-actions FlashList mount/scroll positioning to drive off initialScrollIndex + initialScrollIndexParams (tied to windowHeight) and shipped a new FlashList patch, and it is the only newly-deployed PR in this release that touches the exact render path where the crash surfaces (report actions list re-layout after the whisper is dismissed and the window is resized). Reverting is clean since it is a self-contained scroll/render change.

Assigned: @VickyStash (PR author), @aimane-chnaif and @JS00001 (approving reviewers) Labels: No change β€” DeployBlockerCash kept (frontend bug, App deploy is blocked). No DeployBlocker present, so nothing removed.

πŸ“‹ Detailed Analysis

Evidence

  • Repro is layout/re-layout driven. The corrected repro from @m-natarajan is: submit expense β†’ click "Nothing for now" β†’ then reduce the window size β†’ error. So the crash is not in the dismiss call (which is layout-agnostic, as noted in the earlier analysis), but in the report-actions list re-computing its layout after (a) the dismissed whisper shrinks renderedVisibleReportActions and (b) a window resize forces FlashList to recompute.
  • Only #95045 touches this path in this release. Scanning all PRs on the current StagingDeployCash #95677 for the whisper / report-actions-list / narrow-layout render path:
    • #95045 β€” reworks src/pages/inbox/report/ReportActionsList.tsx, src/hooks/useReportActionsScroll.ts, the InvertedFlashList wrapper, and adds a new FlashList initialScrollIndex patch. Direct hit.
    • #94928 β€” only MoneyRequestReportView/MoneyRequestReportNavigation.tsx (the money-request report view nav, not the DM chat where the whisper renders). Not the repro path.
    • #95606 β€” touches WhisperBanner.tsx/FloatingMessageCounter.tsx but is a cosmetic icon-prop rename (expensifyIcons.Eye) from an icon-sizing lint fix. Ruled out.
    • #95048 (Decompose Icon), #95639 (avatar initials), #95318 (notification/report actions logic) β€” none touch the list render/scroll path. Ruled out.
  • Timeline fits a fresh staging-only regression. #95045 merged 2026-07-09 (the same day this blocker was filed) and is in this staging release but not production β€” matching "reproducible in staging, not production." The earlier "could not reproduce on main (5fadbf3)" note predates this PR's merge.

Verification

  • Affected render path: src/pages/inbox/report/ReportActionsList.tsx and src/hooks/useReportActionsScroll.ts (the self-DM chat whisper renders in ReportActionsList, not MoneyRequestReportView).
  • Confirmed #95045 modifies exactly these files (gh pr view 95045 --json files): ReportActionsList.tsx, useReportActionsScroll.ts, InvertedFlashList/index.tsx, useReportUnreadMessageScrollTracking.ts, plus the new @shopify/flash-list improve-scroll-key-handling patch.
  • Confirmed the change is present at current App HEAD (6e2df6b), i.e. still shipping β€” not yet reverted:
    • useReportActionsScroll.ts:160 now calls const {windowHeight} = useWindowDimensions();
    • useReportActionsScroll.ts:418-419 computes initialScrollIndex = renderedVisibleReportActions.length - 1; initialScrollIndexParams = {viewOffset: windowHeight};

Root Cause

Prior to #95045, the list positioned itself with an initialScrollKey and a data-slice handoff (useFlashListScrollKey, now deleted). #95045 replaced that with an explicit initialScrollIndex (= renderedVisibleReportActions.length - 1) plus initialScrollIndexParams.viewOffset = windowHeight, and a new FlashList patch whose applyInitialScrollAdjustment now does recomputeLayouts(0, this.getDataLength() - 1) and reads getLayout(initialScrollIndex).y/.height, plus a bottom-crop loop that calls getLayout(i) across indices.

When the whisper is dismissed the visible-actions array shrinks, and a subsequent window resize re-triggers FlashList's initial-index layout path against the new (shorter) data / new windowHeight-derived offset. If the computed index/offset no longer lines up with a measured layout (index past the shortened data, or an unmeasured layout during the resize recompute), the patch's getLayout(...) returns undefined and the .y/.height/.width read throws β€” a client-side JS error that only appears once a layout change (resize) forces the recompute, which is why it is width/resize-gated and does not reproduce on a stable full-width layout.

Because this is a client-side render crash introduced by an App PR, the fix belongs in Expensify/App (revert #95045), and the App deploy should remain blocked.

MelvinBot avatar Jul 09 '26 18:07 MelvinBot

Done β€” I've unassigned you NicolasBonet, since this deploy blocker isn't related to your changes.

I traced the likely cause to Expensify/App#95045 ("Open linked message at top - 3") and assigned its author VickyStash plus the approving reviewers aimane-chnaif and JS00001, who are better placed to own it. That PR reworks the ReportActionsList / useReportActionsScroll scroll-index layout path (and ships a new FlashList patch), which matches the repro: the error surfaces when a resize forces the actions list to recompute after the dismissed "Nothing for now" whisper shrinks the visible-actions array β€” not in the dismiss call itself.

Full investigation details are in the analysis comment above. Recommended next step is a revert of Expensify/App#95045 while it's confirmed.

MelvinBot avatar Jul 09 '26 18:07 MelvinBot

@m-natarajan I can't repo it, could you please share console logs if there is some, maybe it will help

VickyStash avatar Jul 09 '26 18:07 VickyStash

Just requested a retest for this one too

JS00001 avatar Jul 09 '26 18:07 JS00001

Oh... Looks like it was already retested above, one sec

JS00001 avatar Jul 09 '26 18:07 JS00001

I also cant repro it, @m-natarajan could you share the console error please?

JS00001 avatar Jul 09 '26 18:07 JS00001

Demoting, this is reproducible on prod! https://expensify.slack.com/archives/C01GTK53T8Q/p1783627391734589?thread_ts=1783610502.932379&cid=C01GTK53T8Q

JS00001 avatar Jul 09 '26 20:07 JS00001

Video from prod:

https://github.com/user-attachments/assets/2f8137fa-90b6-4a1f-bd0e-00153d208015

Image

VickyStash avatar Jul 09 '26 20:07 VickyStash

Proposal

What is the root cause of that problem?

After submitting an expense in your own chat, the app shows a DecisionModal whose secondary button is the "Nothing for now" option. On a small/narrow layout the modal is opened as a bottom-docked sheet rather than a centered confirm dialog, because DecisionModal picks its type from isSmallScreenWidth:

https://github.com/Expensify/App/blob/98130124dd6e9330a0f955cb41beaf08470248e5/src/components/DecisionModal.tsx#L61-L122

The "Nothing for now" button fires onSecondOptionSubmit directly on press. That handler dismisses the flow and triggers navigation while the bottom-docked modal is still mounted. On a narrow layout, navigation is additionally guarded and re-ordered (see the narrow-layout branching in showReportPage), so navigating during the modal transition on small screens collides with the in-progress route change:

https://github.com/Expensify/App/blob/98130124dd6e9330a0f955cb41beaf08470248e5/src/pages/inbox/sidebar/SidebarLinks.tsx#L48-L127

Because the same button on a wide layout uses the centered CONFIRM modal type, the timing race does not occur there, which matches "not reproducible in production / only when screen size is small".

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

  1. In DecisionModal.tsx, the second option button currently runs onSecondOptionSubmit immediately on press:

https://github.com/Expensify/App/blob/98130124dd6e9330a0f955cb41beaf08470248e5/src/components/DecisionModal.tsx#L61-L122

Defer the follow-up navigation until the bottom-docked modal has finished hiding, instead of running it during the modal transition. Close the modal on press, then let the existing onModalHide prop invoke the action so navigation runs after the sheet unmounts:

<Button
    style={[firstOptionText ? styles.mt3 : styles.mt5, styles.noSelect]}
    onPress={() => {
        onClose?.();
        onSecondOptionSubmit();
    }}
    text={secondOptionText}
    success={isSecondOptionSuccess}
    danger={isSecondOptionDanger}
    large
/>
  1. For the caller that renders this modal with secondOptionText set to "Nothing for now", move the navigation call out of the synchronous onSecondOptionSubmit and into the onModalHide callback that DecisionModal already forwards to Modal, so the route change only happens once the sheet is dismissed. This removes the small-screen race while keeping the wide-screen behavior unchanged, because on wide screens the confirm modal hides synchronously anyway.

This fixes the root cause by guaranteeing the modal is unmounted before any narrow-layout navigation guard runs, so the two no longer compete during the transition.

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

samranahm avatar Jul 10 '26 11:07 samranahm

Current assignee @aimane-chnaif is eligible for the External assigner, not assigning anyone new.

melvin-bot[bot] avatar Jul 10 '26 11:07 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022075542207565328179

melvin-bot[bot] avatar Jul 10 '26 11:07 melvin-bot[bot]

Lets get a contributor on this, unless @VickyStash you'd like to work on it?

JS00001 avatar Jul 10 '26 11:07 JS00001