Skip to content

[$250] Chat is not scrolled to the bottom after creating expense if there is a paid expense in chat #91919

Closed

Description

@applause-bot

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.84-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/folder/13177075/test-cases/41237826
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: iPhone 15 iOS 26.5
App Component: Money Requests

Action Performed:

  1. Sign in to ND
  2. Start a chat with another user you have access to
  3. Send several messages
  4. Send an expense
  5. As another user on secondary device, mark the expense as paid
  6. As the main user, make sure there is no unread messages in the chat, scroll to the top of the chat
  7. Submit one more expense

Expected Result:

The chat is scrolled to the bottom to a new submitted expense

Actual Result:

Chat is not scrolled to the bottom after creating expense if there is a paid expense in chat

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7164822_1779924089657.Chat_not_scrolled_after_submitting_expense.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Mita Rachim
Bug ID: 7164822

Upwork Automation - Do Not Edit

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 28, 2026
  2. applause-bot commented on May 28, 2026

    @applause-bot
    Author

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

  3. melvin-bot commented on May 28, 2026

    @melvin-bot

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

  4. melvin-bot commented on May 28, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  5. github-actions commented on May 28, 2026

    @github-actions
    Contributor

    👋 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.
  6. MelvinBot commented on May 28, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    When a user creates a new expense in a chat that already contains a paid/settled expense, the code takes a different path than when the existing expense is still active.

    With a paid expense, shouldCreateNewMoneyRequestReport returns true because canAddOrDeleteTransactions returns false for settled reports. This causes a new REPORT_PREVIEW action to be inserted into the chat (a brand-new item at index 0 of the inverted list).

    Without a paid expense, the existing REPORT_PREVIEW is updated in-place — no new list item is inserted.

    The scroll-to-bottom mechanism in scrollToBottomForCurrentUserAction handles these two cases differently:

    • Updated REPORT_PREVIEW (no paid expense): findIndex finds the existing action at its measured position → scrollToIndex(index) scrolls to a known, already-laid-out position. ✅
    • New REPORT_PREVIEW (paid expense): The new action is at index 0 → falls into the else branch calling scrollToBottom() → scrollToIndex({index: 0}). ❌

    The problem is that when the user has scrolled to the top of the chat (past 250px), shouldMaintainVisibleContentPosition becomes true, which enables maintainVisibleContentPosition on the FlashList. With MVCP enabled and the new REPORT_PREVIEW item just inserted at the head of the inverted list, scrollToIndex({index: 0, animated: false}) on iOS doesn't reliably reach the newly inserted item because the item hasn't been laid out yet and MVCP is actively adjusting content offset to keep the currently visible content stable.

    Additionally, REPORT_PREVIEW actions are explicitly excluded from the shouldJumpToLiveTail mechanism (which would otherwise reload the newest page via openReport and reliably scroll to bottom). The backup scroll via useScrollToEndOnNewMessageReceived also doesn't fire because the user's scroll offset exceeds AUTOSCROLL_TO_TOP_THRESHOLD.

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

    In scrollToBottomForCurrentUserAction, stop unconditionally excluding REPORT_PREVIEW actions from the shouldJumpToLiveTail path. When the user has scrolled away from the bottom (hasNewerActions is true or the scroll offset exceeds the threshold), a new REPORT_PREVIEW should be allowed to use the live-tail jump mechanism (openReport → scroll to bottom → prune) the same way other action types do. This ensures the newest page is properly loaded and the scroll reliably reaches the new item.

    Specifically, change the shouldJumpToLiveTail condition to only bypass REPORT_PREVIEW when the user is already near the bottom (i.e., the action is visible in the current window), not when the user is scrolled far away.

    What alternative solutions did you explore? (Optional)

    1. Add a requestAnimationFrame delay before scrollToBottom() in the REPORT_PREVIEW handler to let the newly inserted item's layout settle before scrolling. This would be simpler but fragile — it's a timing hack that may not work on all devices.

    2. Temporarily disable maintainVisibleContentPosition before scrolling and re-enable it after. This addresses the MVCP interference directly but is complex to implement cleanly and could cause visual jumps in other scenarios.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  7. IuliiaHerets commented on May 28, 2026

    @IuliiaHerets

    Reproduced on iPhone 12/iOS 26.5/Build 9.3.84-1

    92e60810-aa9e-48a5-8c72-ebb473ab887e.mp4
  8. IuliiaHerets commented on May 28, 2026

    @IuliiaHerets

    Reproducible on iPhone 13/iOS 26.3 v9.3.88-0

    ScreenRecording_05-28-2026.17-26-10_1.MP4
  9. 10 remaining items

  10. mountiny commented on May 29, 2026

    @mountiny
    Contributor

    Apparently this is still repro in production. @huult can you please review the proposals?

  11. huult commented on May 29, 2026

    @huult
    Contributor

    sure

  12. wildan-m commented on May 29, 2026

    @wildan-m
    Contributor

    Proposal updated — added compare branch with implementation.

  13. KJ21-ENG commented on May 29, 2026

    @KJ21-ENG
    Contributor

    Proposal

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

    After a user scrolls away from the bottom of a 1:1 chat, submitting a new expense should bring the chat back to the newest expense preview. On iOS this fails when the chat already has a paid expense.

    What is the root cause of that problem?

    Submitting the expense eventually calls notifyNewAction(activeReportID, reportPreviewAction, true) from requestMoney:

    if (activeReportID && !isMoneyRequestReport) {
    Navigation.setNavigationActionToMicrotaskQueue(() =>
    setTimeout(() => {
    notifyNewAction(activeReportID, reportPreviewAction, payeeAccountID === currentUserAccountIDParam);
    }, CONST.TIMING.NOTIFY_NEW_ACTION_DELAY),

    That drives scrollToBottomForCurrentUserAction in the report action list. For a REPORT_PREVIEW, the code already delays scrollToIndex(index) when the preview exists at index > 0, but it calls scrollToBottom() immediately when the preview is at index === 0 or is not found yet:

    const index = sortedVisibleReportActions.findIndex((item) => item.reportActionID === action?.reportActionID);
    if (action?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW) {
    if (index > 0) {
    setTimeout(() => {
    reportScrollManager.scrollToIndex(index);
    }, 100);
    } else {
    setIsFloatingMessageCounterVisible(false);
    reportScrollManager.scrollToBottom();
    }

    On native, scrollToBottom() is implemented as scrollToIndex({index: 0}) on the inverted list:

    const scrollToBottom = () => {
    if (!flatListRef?.current) {
    return;
    }
    scrollPositionRef.current = {offset: 0};
    flatListRef.current.scrollToIndex({animated: false, index: 0});

    The paid-expense case is the path that exposes this. A paid IOU report cannot accept the new transaction, so the new expense creates a new money request report and a new parent REPORT_PREVIEW at the head of the inverted FlashList. At the moment the current-user action event runs, that new row can be in Onyx but not yet measured/laid out by iOS FlashList. The immediate scrollToIndex(0) is therefore issued too early and does not move the user from the older scroll position.

    The normal existing-preview path avoids this because it uses a delayed scrollToIndex(index). The fallback setIsScrollToBottomEnabled(true) does not reliably cover the missed case because it is consumed in the list container onLayout, which does not necessarily fire for a newly inserted row:

    const onLayoutInner = useCallback(
    (event: LayoutChangeEvent) => {
    onLayout(event);
    if (isScrollToBottomEnabled) {
    reportScrollManager.scrollToBottom();
    setIsScrollToBottomEnabled(false);
    completeLiveTailPruneAfterScrollToBottom();
    }

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

    In src/pages/inbox/report/useReportActionsNewActionLiveTail.ts, use the same deferred-scroll strategy for the REPORT_PREVIEW index <= 0 branch that the index > 0 branch already uses.

    Concretely, extract a small helper in the hook, for example deferScrollToBottom(), that clears the floating counter and calls reportScrollManager.scrollToBottom() inside the existing short timeout used for preview scrolling. Then:

    • keep the existing index > 0 scrollToIndex(index) behavior for already-mounted preview rows;
    • call the deferred bottom-scroll helper for REPORT_PREVIEW when index <= 0;
    • use the same helper for other current-user actions that insert at the newest position, so the behavior is consistent for newly inserted head rows.

    This keeps the existing live-tail/openReport logic intact and only changes the timing of the scroll command in the path where the target row may not be measured yet.

    What alternative solutions did you explore? (Optional)

    We could route REPORT_PREVIEW through the live-tail openReport -> scroll -> prune path when the user is away from the bottom, but that is heavier than necessary for a local optimistic expense submit.

    We could also wire this to onContentSizeChange, but that is broader and would need more guards around pagination and edits. A targeted deferred scroll matches the established pattern already used beside the broken branch.

  14. aswin-s commented on May 29, 2026

    @aswin-s
    Contributor

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  15. github-actions commented on May 29, 2026

    @github-actions
    Contributor

    ⚠️ @aswin-s 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.

  16. yusufdeveloper2903 commented on May 29, 2026

    @yusufdeveloper2903
    Contributor

    Proposal

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

    After submitting an expense in a 1:1 chat, the chat does not scroll down to the newly created expense when an already‑paid expense exists in that chat (the view stays where it was instead of jumping to the live tail).

    What is the root cause of that problem?

    New‑action scrolling is handled in scrollToBottomForCurrentUserAction. When the user is scrolled away from the live tail (hasNewerActions === true), the handler normally performs a "live‑tail jump" (openReport → scroll to bottom → prune) so the user lands on the freshly created action. That jump is intentionally skipped for every REPORT_PREVIEW action:

    const shouldJumpToLiveTail =
    !isOffline && action?.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && (hasNewerActions || !!linkedReportActionID || unreadMarkerReportActionID);

    The exclusion exists to preserve the "auto‑merge" behavior added for grouped expenses: when a new expense merges into an existing open report, its preview stays mid‑list and we scroll‑to‑index + highlight it instead of jumping to the bottom:

    const index = sortedVisibleReportActions.findIndex((item) => item.reportActionID === action?.reportActionID);
    if (action?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW) {
    if (index > 0) {
    setTimeout(() => {
    reportScrollManager.scrollToIndex(index);
    }, 100);
    } else {
    setIsFloatingMessageCounterVisible(false);
    reportScrollManager.scrollToBottom();
    }
    if (action?.reportActionID) {
    setActionIdToHighlight(action.reportActionID);
    }
    } else {

    This is exactly why the bug is specific to "a paid expense in chat":

    • Previous expense still open → the new expense merges into the existing report, so the preview that arrives is the already‑loaded mid‑list preview. index > 0, scrollToIndex(index) works, and the merged expense is shown. No bug.
    • Previous expense paid (settled) → canAddOrDeleteTransactions returns false for a REIMBURSED report, so shouldCreateNewMoneyRequestReport is true and a brand‑new report + brand‑new preview is created at the live tail (TrackExpense.ts#L1102-L1113, settled check at ReportUtils.ts#L2752-L2770). That preview is then sent to the handler (TrackExpense.ts#L1912-L1916).

    Because the user scrolled up, the newest window isn't loaded, so this new preview is not in sortedVisibleReportActions → index === -1. The blanket actionName !== REPORT_PREVIEW exclusion suppresses the live‑tail jump, and index === -1 is not > 0, so the code falls into scrollToBottom() — which only scrolls to the bottom of the stale, loaded window, never reaching the actual new expense at the live tail.

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

    Only keep a REPORT_PREVIEW out of the live‑tail jump when it is the auto‑merge case (an existing preview already loaded at index > 0). A brand‑new preview that isn't in the loaded window must take the normal live‑tail jump. We hoist the existing findIndex above the guard so it drives both decisions:

    -            const shouldJumpToLiveTail =
    -                !isOffline && action?.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && (hasNewerActions || !!linkedReportActionID || unreadMarkerReportActionID);
    +            const index = sortedVisibleReportActions.findIndex((item) => item.reportActionID === action?.reportActionID);
    +            // Keep only an auto-merged preview (already loaded at index > 0) out of the live-tail jump so it can be
    +            // scrolled-to + highlighted below. A brand-new preview (e.g. a new report created because the previous
    +            // expense is settled) is not in the loaded window while scrolled up, so it must jump to the live tail.
    +            const isAutoMergedReportPreview = action?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && index > 0;
    +            const shouldJumpToLiveTail =
    +                !isOffline && !isAutoMergedReportPreview && (hasNewerActions || !!linkedReportActionID || unreadMarkerReportActionID);

    Then remove the now‑duplicate const index = sortedVisibleReportActions.findIndex(...) on line 110 and let the lower REPORT_PREVIEW branch reuse the hoisted index. No other lines change.

    • Paid case (new preview, scrolled up): index === -1 → isAutoMergedReportPreview === false → shouldJumpToLiveTail becomes true → openReport loads the newest window and scrolls to the live tail. ✅
    • Auto‑merge case (existing preview, index > 0): unchanged → scrollToIndex(index) + highlight. ✅
    • Brand‑new preview when already at the tail (index === 0, hasNewerActions === false): unchanged → falls through to scrollToBottom(). ✅

    Files: src/pages/inbox/report/useReportActionsNewActionLiveTail.ts only. Not touched: IOU/data layer (the optimistic data is already correct — only the scroll heuristic is wrong). Platforms: fix is in shared code; verified for iOS App per the report.

    What alternative solutions did you explore? (Optional)

    • Drop the REPORT_PREVIEW exclusion entirely in shouldJumpToLiveTail — rejected: it would break the intended auto‑merge scroll‑to‑index + highlight for expenses merged into an existing open report (the preview would jump to the bottom instead of highlighting in place).
    • In the else branch, call the live‑tail jump when index === -1 instead of scrollToBottom() — rejected: it duplicates the jump logic in a second place and reorders the highlight/setActionIdToHighlight flow; gating shouldJumpToLiveTail keeps a single jump path.
    • Force openReport on every expense creation — rejected: unnecessary network round‑trip when the new preview is already loaded at the tail (the common, not‑scrolled‑up case).
  17. github-actions commented on May 29, 2026

    @github-actions
    Contributor

    ⚠️ @yusufdeveloper2903 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.

  18. JoesyP commented on May 31, 2026

    @JoesyP

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  19. github-actions commented on May 31, 2026

    @github-actions
    Contributor

    ⚠️ @JoesyP 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.

  20. huult commented on Jun 1, 2026

    @huult
    Contributor
    ScreenRecording_06-01-2026.09-06-06_1.MP4

    Hi contributors, is anyone still able to reproduce this issue?

    @IuliiaHerets can you still reproduce this issue?

  21. IuliiaHerets commented on Jun 1, 2026

    @IuliiaHerets

    @huult Issue is not repro anymore on 9.3.90-1

    New.expense.scroll.mp4
  22. huult commented on Jun 2, 2026

    @huult
    Contributor

    @madmax330 #91919 (comment) As this issue is no longer reproducible, we can close this ticket.

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions