Skip to content

Chat - Chat is scrolling up after editing a message #86813

Closed

Description

@vincdargento

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.51-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/TR-14589/folder/13176723/41237031/1295548358
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Web
App Component: Other

Action Performed:

  1. Navigate to ND
  2. Open a chat with some history
  3. Send a message
  4. Right click on the message
  5. Click on "Edit Comment"
  6. Edit the message and press ENTER

Expected Result:

Chat should maintain in the same position after editing a message.

Actual Result:

After editing a message chat is automatically scrolling up.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

bug.mp4

View all open jobs on GitHub

Activity

  1. added
    DeployBlockerCash
    Daily
    Bug
    on Mar 31, 2026
  2. melvin-bot commented on Mar 31, 2026

    @melvin-bot

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

  3. melvin-bot commented on Mar 31, 2026

    @melvin-bot

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

  4. github-actions commented on Mar 31, 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.
  5. OSBotify commented on Mar 31, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #86119 - "decompose ReportScreen 5: self-subscribe List and Composer" by @adhorodyski (Medium confidence)
    Related Issues: None found

    Recommendation: NEEDS INVESTIGATION

    The bug describes chat scrolling up after editing a message, which only reproduces on staging (not production). PR #86119 refactored ReportActionsView and ReportActionCompose components, making them self-subscribing and reducing prop drilling. This refactor could have inadvertently affected scroll position maintenance when messages are edited.

    Rationale: While PR #86119 is the most likely candidate due to its timing (merged March 30) and scope (refactoring report view components), I cannot definitively confirm it touches message edit scroll behavior without deeper code analysis. The PR mentions it reduced ReportActionsView from 13 props to 2 and ReportActionCompose from 11 props to 1, which could affect how the component re-renders when a message is edited.

    Labels: Keep DeployBlockerCash (this is a frontend bug affecting staging)

    Detailed Analysis

    Evidence

    • Bug is staging-only, not reproducible in production
    • Affects Windows Chrome (web platform)
    • Version: 9.3.51-0
    • The issue occurs specifically when editing a message and pressing ENTER
    • Expected: Chat should maintain scroll position
    • Actual: Chat automatically scrolls up

    Candidate PRs Investigated

    From the StagingDeployCash checklist for v9.3.51-0, I examined recent PRs that could affect chat/message behavior:

    1. PR decompose ReportScreen 5: self-subscribe List and Composer #86119 (MOST LIKELY) - "decompose ReportScreen 5: self-subscribe List and Composer"

      • Merged: March 30, 2026
      • Major refactor of ReportActionsView and ReportActionCompose
      • Changed from prop-drilling architecture to self-subscribing components
      • Modified how report actions are rendered and updated
      • Could affect scroll position handling during message updates
    2. PR [No QA] perf: remove redundant reportNameValuePairs collection subscription from LHN #86644 - LHN performance optimization (removed redundant NVP subscription)

      • Less likely: Affects sidebar, not report view
    3. PR [NoQA] Removed unused files (batch 1) #86450, [No QA] fix: move AppStartTime recording from MainApplication to MainActivity #86468, [No QA] Add node_modules to module names #86515 - Various No QA changes

      • Unlikely: File cleanup, Android timing, module naming

    Root Cause Hypothesis

    The refactoring in PR #86119 changed how ReportActionsView manages its state and renders. When a message is edited, the component may be re-rendering or re-subscribing in a way that causes the scroll position to reset. The move from prop-based updates to useOnyx subscriptions could be triggering unnecessary list recalculations.

    Next Steps

    1. @adhorodyski - PR author should verify if scroll position preservation logic was maintained during the refactor
    2. Check if ReportActionsList scroll position is being preserved when ReportActionsView updates
    3. Verify if the message edit completion triggers a full list re-render instead of a targeted update
    4. Test reverting PR decompose ReportScreen 5: self-subscribe List and Composer #86119 to confirm if it resolves the issue
  6. Julesssss commented on Mar 31, 2026

    @Julesssss
    Contributor

    @MelvinBot investigate this, try and locate the PR that caused this

  7. vincdargento commented on Mar 31, 2026

    @vincdargento
    Author

    Culprit PR was not identified, the issue is reproducible in every snapshot build of the checklist

  8. MelvinBot commented on Mar 31, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    PR #80122 migrated the chat list in ReportActionsList.tsx from InvertedFlatList to a non-inverted FlatListWithScrollKey (with manually reversed data). This architectural change broke scroll position maintenance during message editing because:

    1. MVCP (Maintain Visible Content Position) is disabled in normal viewing mode. In useFlatListScrollKey.ts:119-121, maintainVisibleContentPosition returns undefined when there is no initialScrollKey (i.e. not linked to a specific message). This means the MutationObserver in the web FlatList (src/components/FlatList/FlatList/index.tsx:127) early-returns from adjustForMaintainVisibleContentPosition without compensating for content size changes.

    2. In the old inverted list, the scroll anchor was at offset 0 (= bottom/newest messages). When the edit composer was removed and content shrank, the browser naturally kept the visual position stable. In the new non-inverted list, the scroll anchor is at offset 0 (= top/oldest messages). When the edit composer is removed and content height decreases, the scroll position from the top stays fixed while the content shifts upward, causing the visible "scroll up" effect.

    3. Additionally, ReportActionItemMessageEdit.tsx:119 calls useReportScrollManager() with the default isInverted=true, while the list now uses useReportScrollManager(false). This causes deleteDraft's scrollToIndex(0) call (line 296-299) to reference index 0 of the reversed flatListData array (= oldest message) instead of the newest message.

    This is the same PR causing related deploy blockers #86787 and #86794.

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

    Two changes are needed:

    1. Enable MVCP during edit mode: Ensure that maintainVisibleContentPosition in useFlatListScrollKey.ts is active (not undefined) when the edit composer is being shown/removed, so the MutationObserver's adjustForMaintainVisibleContentPosition can compensate for the height change. Alternatively, the adjustForMaintainVisibleContentPosition function in FlatList/index.tsx could be modified to not early-return when mvcpMinIndexForVisible == null if it detects an edit composer change (it already has isEditComposerAdded detection at line 160-175).

    2. Fix the scroll manager mismatch: Update ReportActionItemMessageEdit.tsx:119 to use useReportScrollManager(false) to match the non-inverted list orientation. The scrollToIndex call in deleteDraft also needs to account for the reversed data array (index 0 in the original sorted data = last index in flatListData).

    What alternative solutions did you explore? (Optional)


    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.

  9. MelvinBot commented on Mar 31, 2026

    @MelvinBot
    Contributor

    The culprit PR is #80122 ("Fix: Keyboard Navigation: Paid expense details").

    Evidence:

    What it changed: PR #80122 migrated the chat message list in ReportActionsList.tsx from InvertedFlatList to a non-inverted FlatListWithScrollKey with manually reversed data. This architectural change broke the scroll position maintenance that previously worked naturally with the inverted list orientation. See my earlier analysis for full root cause details and recommended fix.

    All three deploy blockers (#86787, #86794, #86813) stem from this same PR and would be resolved by either fixing the MVCP behavior in the non-inverted list or reverting PR #80122.

  10. Julesssss commented on Apr 1, 2026

    @Julesssss
    Contributor

    This should have been resolved with this revert CP: #86802

    I requested QA testing for verification.

  11. Julesssss commented on Apr 1, 2026

    @Julesssss
    Contributor

    Requested QA testing again

  12. m-natarajan commented on Apr 1, 2026

    @m-natarajan

    Not repro on Mac 15.4.1 Safari, v9.3.51-7

    Recording.1923.mp4
  13. removed
    DeployBlockerCash
    on Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugEngineeringHourly

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions