App icon indicating copy to clipboard operation
App copied to clipboard

[Due for payment 2026-11-16] [$175] Chat - "Latest messages" pill remains visible after sending a message

Open applause-bot[bot] opened this issue 3 weeks ago • 36 comments

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.5.32-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://github.com/Expensify/App/pull/104242 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: Mac 26.5.1 Safrai, iPhone 13 iOS 26.6 App Component: Chat Report View

Action Performed:

  1. Go to https://staging.new.expensify.com
  2. Open a chat from a deep link to an old message
  3. Send a message. Verify the list jumps to the newest messages and your message is visible.

Expected Result:

The "Latest messages" pill should disappear after sending a message and the chat jumps to the newest messages.

Actual Result:

"Latest messages" pill remains visible after sending a message and jumping to the newest messages

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/68841592-06ec-4e66-9c6b-4fff83cf61f2

View all open jobs on GitHub

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

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

applause-bot[bot] avatar Nov 04 '26 21:11 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/856c26d65da95854a9a909090893790e861bbb6206a51b00fe02424d2612f4c1

applause-bot[bot] avatar Nov 04 '26 21:11 applause-bot[bot]

🤖 Web test steps verification results: ⚠️ partial

The handed-over dev NewDot web session was accessible. Missing historical-message fixtures blocked reproduction of issue 106015.

Concierge history containing only its welcome message
Step Status
1. Open the app in the handed-over sessionAuthenticated Home and Inbox rendered.
✅
2. Open an old-message deep link with newer messages offscreenFixture blocked: available Concierge history contained only its welcome message, without an eligible old-message link and newer-message history.
Concierge history containing only its welcome message
❌
3. Send and verify newest messages and the sent message become visibleNot executed: blocked by the missing historical-message fixture.
❌
4. Verify Latest messages disappears after the jumpNot executed: the required send-triggered jump could not be tested. The pill's presence alone does not reproduce the issue.
❌

view run

MelvinBot avatar Nov 04 '26 22:11 MelvinBot

Proposal

What is the root cause of that problem?

Likely stale scroll tracking after the jump; medium confidence, not reproduced. Sending hides the pill, but a subsequent content-size callback can show it again using the historical scroll offset. The deferred jump does not synchronize that offset or pill visibility.

Code evidence and limits

Web verification was blocked by missing historical-message fixtures. The event sequence remains unconfirmed.

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

Add a regression test covering deep-link list replacement, stale offset, content-size callbacks, and no subsequent scroll event. Synchronize offset and pill visibility when the newest-page jump completes, guarded by list readiness. Avoid unconditionally assuming a scroll request succeeded.

Verify scrolling upward restores the pill; cover offline sends and unread markers.


Next Steps for Contributor+ team: To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/106015) to create a draft PR. To refine: @MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.


view run · view recording

MelvinBot avatar Nov 04 '26 22:11 MelvinBot

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

melvin-bot[bot] avatar Nov 04 '26 22:11 melvin-bot[bot]

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

melvin-bot[bot] avatar Nov 04 '26 22:11 melvin-bot[bot]

Proposal

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

When opening a chat via a deep link to an older message (where the "Latest messages" pill is visible) and sending a new message, the chat list jumps to the newest messages at the bottom, but the "Latest messages" pill remains visible on screen instead of disappearing.

What is the root cause of that problem?

When a report is opened at a deep-linked older message (linkedReportActionID), scrollOffsetRef.current (provided by ActionListContext above InvertedFlashList) holds the non-zero scroll offset (> CONST.REPORT.ACTIONS.ACTION_VISIBLE_THRESHOLD) from the deep-linked position, and isFloatingMessageCounterVisible is true.

When the current user sends a message from that deep-linked view, useReportActionsNewActionLiveTail.ts runs the live-tail jump sequence:

  1. scrollToBottomForCurrentUserAction (lines 125-136) calls openReportAtLiveTail() and sets liveTailJumpRef.current = {stage: 'open_report'}.
  2. Once openReport finishes loading (src/pages/inbox/report/useReportActionsNewActionLiveTail.ts, lines 191-205), it sets setTreatAsNoPaginationAnchor(true), calls clearLinkedActionParam() (navigation.setParams({reportActionID: ''})), and transitions to stage: 'await_scroll'.
  3. In the next effect (src/pages/inbox/report/useReportActionsNewActionLiveTail.ts, lines 207-221), once hasNewestReportAction is true, it calls setIsFloatingMessageCounterVisible(false) and schedules setIsScrollToBottomEnabled(true) in a microtask:
        liveTailJumpRef.current = {stage: 'await_prune'};
        setIsFloatingMessageCounterVisible(false);
        // Defer so this effect does not synchronously chain a second render from setState (eslint react-hooks/set-state-in-effect).
        queueMicrotask(() => {
            setIsScrollToBottomEnabled(true);
        });
  1. Clearing linkedReportActionID changes listID in src/pages/inbox/report/ReportActionsList/useReportActionsListScroll.ts (line 71: const listID = [reportID, linkedReportActionID, ...].join(':')), which is passed as key={listID} to <InvertedFlashList> (ReportActionsListContent.tsx, line 265). This remounts InvertedFlashList at the bottom (index 0, scroll offset 0), while ActionListContext's scrollOffsetRef.current remains mounted above it and still retains the stale deep-link offset (> ACTION_VISIBLE_THRESHOLD).
  2. When the remounted list fires onContentSizeChange (src/pages/inbox/report/ReportActionsList/useReportActionsListScroll.ts, lines 214-217):
            onContentSizeChange: () => {
                trackVerticalScrolling(undefined);
                flushPendingScrollToBottom();
            },

trackVerticalScrolling(undefined) calls updatePillVisibility() (src/pages/inbox/report/useReportUnreadMessageScrollTracking.ts, lines 98-120) with event === undefined, so scrollOffsetRef.current is not updated. Because scrollOffsetRef.current still holds the old deep-link offset (> CONST.REPORT.ACTIONS.ACTION_VISIBLE_THRESHOLD) and isFloatingMessageCounterVisible was just set to false, updatePillVisibility() immediately sets setIsFloatingMessageCounterVisible(true) again! 6. Right after that, flushPendingScrollToBottom() runs (src/hooks/useReportActionsScroll.ts, lines 426-433):

    const flushPendingScrollToBottom = () => {
        if (!isScrollToBottomEnabled) {
            return;
        }
        reportScrollManager.scrollToBottom();
        setIsScrollToBottomEnabled(false);
        completeLiveTailPruneAfterScrollToBottom();
    };

Because the remounted InvertedFlashList is already positioned at index 0 (or scrollToIndex({index: 0, animated: false}) is a no-op at offset 0), no native onScroll event is emitted, scrollOffsetRef.current is never reset to 0, and flushPendingScrollToBottom() never hides the pill or clears the stale offset. Furthermore, any subsequent onContentSizeChange callback after flushPendingScrollToBottom() will continue reading the stale scrollOffsetRef.current > ACTION_VISIBLE_THRESHOLD and re-showing the pill.

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

In src/hooks/useReportActionsScroll.ts inside flushPendingScrollToBottom (lines 426-433), reset scrollOffsetRef.current = 0 and call setIsFloatingMessageCounterVisible(false) when flushing the pending scroll to the bottom:

    const flushPendingScrollToBottom = () => {
        if (!isScrollToBottomEnabled) {
            return;
        }
        scrollOffsetRef.current = 0;
        setIsFloatingMessageCounterVisible(false);
        reportScrollManager.scrollToBottom();
        setIsScrollToBottomEnabled(false);
        completeLiveTailPruneAfterScrollToBottom();
    };

Resetting scrollOffsetRef.current = 0 and hiding the floating message counter in flushPendingScrollToBottom ensures that:

  • Even if onContentSizeChange ran trackVerticalScrolling(undefined) right before flushPendingScrollToBottom() (or while isScrollToBottomEnabled was queued), the pill is hidden once the jump to the bottom is flushed.
  • Any subsequent onContentSizeChange (trackVerticalScrolling(undefined)) sees scrollOffsetRef.current === 0 (matching the actual bottom position of the list) and does not re-enable the pill until the user actually scrolls up in history.

What alternative solutions did you consider?

We considered resetting scrollOffsetRef.current = 0 when listID changes in useReportActionsListScroll.ts, or swapping the order of flushPendingScrollToBottom() and trackVerticalScrolling(undefined) in onContentSizeChange. However, onContentSizeChange can also fire on the render before the queueMicrotask(() => setIsScrollToBottomEnabled(true)) state update commits, and flushPendingScrollToBottom is also called from onLayout and non-remount live-tail jumps (where hasNewerActions was true without a linkedReportActionID change). Synchronizing scrollOffsetRef.current = 0 and setIsFloatingMessageCounterVisible(false) directly inside flushPendingScrollToBottom() handles both deep-link remount jumps and in-place live-tail jumps in one place.

aion-citadel-forge avatar Nov 04 '26 22:11 aion-citadel-forge

Proposal

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

When opening a chat from a deep link to an old message and then sending a message, the chat list jumps to the newest messages at the bottom, but the "Latest messages" floating pill remains visible instead of disappearing.

What is the root cause of that problem?

  1. When a chat is opened from a deep link (linkedReportActionID in route params), <InvertedFlashList key={listID} /> mounts at initialScrollIndex = targetIndex (> 0). Its onScroll handler (trackScrollPositionAndThreshold in src/pages/inbox/report/ReportActionsList/useReportActionsListScroll.ts, lines 146-149) sets scrollOffsetRef.current (stored in ActionListContextProvider, src/pages/inbox/ActionListContext.tsx, line 53) to the deep-linked scroll offset (> CONST.REPORT.ACTIONS.ACTION_VISIBLE_THRESHOLD) and calls onScrolledOverThresholdChange(true) (hasScrolledOverThreshold = true in ReportActionsListContent.tsx, line 119). Once onLoad runs (src/hooks/useReportActionsScroll.ts, lines 436-443), updatePillVisibility() sees currentVerticalScrollingOffsetRef.current > CONST.REPORT.ACTIONS.ACTION_VISIBLE_THRESHOLD and sets isFloatingMessageCounterVisible = true.
  2. When the current user sends a message while viewing the deep-linked message, scrollToBottomForCurrentUserAction in src/pages/inbox/report/useReportActionsNewActionLiveTail.ts (lines 125-136) enters the shouldJumpToLiveTail branch (!!linkedReportActionID is true), sets liveTailJumpRef.current = {stage: 'open_report'}, and calls openReportAtLiveTail().
  3. When openReport finishes (prevIsLoadingInitialReportActions === true && reportLoadingState?.isLoadingInitialReportActions === false), two separate effects in useReportActionsNewActionLiveTail.ts run across consecutive renders:
    • First, the effect at lines 191-205 runs:
      setTreatAsNoPaginationAnchor(true);
      clearLinkedActionParam();
      liveTailJumpRef.current = {stage: 'await_scroll'};
      
      clearLinkedActionParam() calls navigation.setParams({reportActionID: ''}), changing linkedReportActionID to ''.
    • In the render caused by setTreatAsNoPaginationAnchor(true) and clearLinkedActionParam(), listID in useReportActionsListScroll.ts (line 71: [reportID, linkedReportActionID, ...].join(':')) changes immediately. This unmounts the deep-linked <InvertedFlashList key={listID} /> and mounts a brand-new <InvertedFlashList> instance at scroll offset 0 (initialScrollIndex = undefined).
    • Crucially, during the render in which the new <InvertedFlashList> mounts and fires its initial onLayout and onContentSizeChange, isScrollToBottomEnabled is still false, because the second effect at lines 207-221:
      liveTailJumpRef.current = {stage: 'await_prune'};
      setIsFloatingMessageCounterVisible(false);
      queueMicrotask(() => {
          setIsScrollToBottomEnabled(true);
      });
      
      only runs after hasNewestReportAction becomes true (once treatAsNoPaginationAnchor is true), and then further defers setIsScrollToBottomEnabled(true) inside a queueMicrotask.
  4. Because the remounted <InvertedFlashList> starts at offset 0, it never emits an onScroll event. Meanwhile, scrollOffsetRef.current in ActionListContextProvider still holds the stale deep-linked offset (> CONST.REPORT.ACTIONS.ACTION_VISIBLE_THRESHOLD), and hasScrolledOverThreshold in ReportActionsListContent remains true (which also leaves maintainVisibleContentPosition.disabled = false and useMarkAsRead's isScrolledToEnd = false).
  5. When onContentSizeChange fires on the list (useReportActionsListScroll.ts, lines 214-217):
    onContentSizeChange: () => {
        trackVerticalScrolling(undefined);
        flushPendingScrollToBottom();
    },
    
    • If onContentSizeChange fires before the queueMicrotask sets isScrollToBottomEnabled = true, flushPendingScrollToBottom() returns early at if (!isScrollToBottomEnabled) return;. And once isScrollToBottomEnabled flips to true on the subsequent render, if layout and content size have already settled on the remounted list, flushPendingScrollToBottom() (and completeLiveTailPruneAfterScrollToBottom()) does not run until a future layout/content-size event.
    • And whenever onContentSizeChange runs (either during initial layout or after pruneReportActionPagesToNewestWindow prunes older pages), trackVerticalScrolling(undefined) calls updatePillVisibility() (src/pages/inbox/report/useReportUnreadMessageScrollTracking.ts, lines 98-110), which reads the stale currentVerticalScrollingOffsetRef.current > CONST.REPORT.ACTIONS.ACTION_VISIBLE_THRESHOLD and immediately calls setIsFloatingMessageCounterVisible(true), turning the "Latest messages" pill back on.
  6. Offending PR / Regression History:
    • In PR #90072 (4ac01f2d, Open reports at first unread action V2), key={listID} was originally placed on <ReportActionsList key={listID} /> in ReportActionsView.tsx.
    • In PR #94149 (856bc8e1, Decompose ReportActionsList: 10), key={listID} was moved down onto <InvertedFlashList key={listID} /> while ReportActionsListContent was keyed by key={reportID}, so useReportActionsScroll, useReportUnreadMessageScrollTracking, and ActionListContext's scrollOffsetRef.current remained mounted when clearLinkedActionParam() remounted <InvertedFlashList key={listID} /> at offset 0.
    • In PR #100793 (088b2bb3, Show the Latest messages pill in a read chat when scrolled up past the visible threshold), the pill threshold in useReportUnreadMessageScrollTracking.ts was lowered from LATEST_MESSAGES_PILL_SCROLL_OFFSET_THRESHOLD (2000) to ACTION_VISIBLE_THRESHOLD (250), causing trackVerticalScrolling(undefined) on onContentSizeChange to re-show the pill whenever the stale deep-linked scrollOffsetRef.current > 250. (PR #103174 / 2403f672 and PR #104845 / c9084eb8 further wired flushPendingScrollToBottom() after trackVerticalScrolling(undefined) in onContentSizeChange and added the offline linked-action anchor release; PR #104242 / bc5e11df on the current staging checklist #105971 only refactored openReportAtLiveTail to read Onyx inputs via Onyx.multiGet / Onyx.get, which is why the regression test on #104242 surfaced this pre-existing behavior.)

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

  1. Reset scrollOffsetRef.current and hasScrolledOverThreshold when releasing the linked-action anchor and jumping to the live tail:
    • Pass onScrolledOverThresholdChange into useReportActionsScroll and expose a resetScrollToBottomState callback (which sets scrollOffsetRef.current = 0, calls onScrolledOverThresholdChange(false), and calls setIsFloatingMessageCounterVisible(false)) to useReportActionsNewActionLiveTail.
    • In src/pages/inbox/report/useReportActionsNewActionLiveTail.ts, call resetScrollToBottomState() when releasing the linked-action anchor (in the open_report completion effect at lines 202-204, the await_scroll effect at lines 215-220, and the offline linked-action send branch at lines 139-143) so that scrollOffsetRef.current is 0 and hasScrolledOverThreshold is false before the remounted <InvertedFlashList key={listID} /> mounts and runs onContentSizeChange.
  2. Flush pending scroll-to-bottom when isScrollToBottomEnabled becomes true and reset scroll state inside flushPendingScrollToBottom:
    • In src/hooks/useReportActionsScroll.ts inside flushPendingScrollToBottom (lines 426-433), also call resetScrollToBottomState(), and invoke flushPendingScrollToBottom() from an effect when isScrollToBottomEnabled becomes true (once the list ref is laid out) so the scroll and pagination prune are not missed if onLayout / onContentSizeChange already fired before the queueMicrotask render:
      const flushPendingScrollToBottom = () => {
          if (!isScrollToBottomEnabled) {
              return;
          }
          scrollOffsetRef.current = 0;
          onScrolledOverThresholdChange(false);
          setIsFloatingMessageCounterVisible(false);
          reportScrollManager.scrollToBottom();
          setIsScrollToBottomEnabled(false);
          completeLiveTailPruneAfterScrollToBottom();
      };
      
  3. Run flushPendingScrollToBottom() before trackVerticalScrolling(undefined) in onContentSizeChange:
    • In src/pages/inbox/report/ReportActionsList/useReportActionsListScroll.ts (lines 214-217):
      onContentSizeChange: () => {
          flushPendingScrollToBottom();
          trackVerticalScrolling(undefined);
      },
      

What alternative solutions did you consider?

  1. Only resetting scrollOffsetRef.current = 0 inside flushPendingScrollToBottom(): This is not sufficient on its own because clearLinkedActionParam() remounts <InvertedFlashList key={listID} /> in the render before queueMicrotask(() => setIsScrollToBottomEnabled(true)) commits, so isScrollToBottomEnabled is still false when the remounted list fires its initial onLayout and onContentSizeChange, and hasScrolledOverThreshold in ReportActionsListContent would also stay true (leaving maintainVisibleContentPosition enabled and useMarkAsRead's isScrolledToEnd as false).
  2. Resetting scrollOffsetRef.current = 0 in ActionListContext.registerListRef on every unmount/mount: ReportActionsListThresholdTest specifically requires scrollOffsetRef.current to persist across mount when preserving scroll position above the threshold. Resetting scrollOffsetRef.current = 0 and onScrolledOverThresholdChange(false) specifically during a live-tail / scroll-to-bottom jump preserves mount-time threshold behavior.

sonofkratos92 avatar Nov 04 '26 22:11 sonofkratos92

Proposal

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

After sending from a historical-message deep link, the chat reportedly reaches the newest messages but retains the “Latest messages” pill. The faulty function and exact line remain unverified.

What is the root cause of that problem?

⚠️ Why MelvinBot's proposal is insufficient / introduces regressions:

  • It explicitly admits no reproduction or confirmed event sequence; stale-offset reuse remains a hypothesis.
  • Resetting tracking on an unconfirmed scroll could hide the pill while the list still displays historical messages.

Verdict: insufficient evidence for implementation approval. The supplied references identify investigation points, not a demonstrated cause. Source retrieval failed, and no local Expensify checkout was available; I could not verify the cited lines.

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

First capture the failing sequence: list replacement, content-size callback, pending-jump execution, actual offset, newest-page availability, and pill visibility.

A 3–10-line TypeScript patch is not defensible until that trace identifies the incorrect state transition. Inventing one would violate the required evidence standard.

Compare branch: https://github.com/Expensify/App/compare/main...camesenin:App:fix-issue-106015?expand=1

Branch existence and contents were not verified.

What alternative solutions did you explore? (Optional)

Unconditional offset resets and hiding on send both risk masking an incomplete jump. Synchronizing after confirmed completion also substantially overlaps MelvinBot’s recommendation; it is not an independently established solution.

What automated tests can you add to prevent this from re-occurring?

In the existing list/hook suite, reproduce the observed callback order and require failure before the fix and success afterward. Cover delayed list readiness, absent scroll events, offline sending, and scrolling upward; no tests were executed.

Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~01b60d704ba377be83

camesenin avatar Nov 04 '26 22:11 camesenin

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 04 '26 22:11 melvin-bot[bot]

@MelvinBot Investigate this issue and write-up a new formal proposal. Find the offending PR if possible (either the latest staging deploy checklist or older).

ikevin127 avatar Nov 04 '26 23:11 ikevin127

🤖 Web test steps verification results: ⚠️ partial

Issue 106015 remains unconfirmed on dev NewDot web. The bounded continuation could not expose the anchor’s Copy link menu; no additional fixture messages or source changes were made.

Search-result chat preview showing newer fixture messages; required old-message state was not established
Step Status
1: App opens in handed-over sessionAuthenticated app and self-chat were accessible.
✅
2: Open genuine old-message permalink with newer messages offscreen and Latest messages visibleBlocked. Approximately 60 genuine test messages were created, but the anchor’s Copy link menu could not be exposed. Search preview did not establish the required deep-link viewport or unambiguous pill presence.
Search-result chat preview showing newer fixture messages; required old-message state was not established
❌
3: Send a message; newest messages and sent message become visibleNot verified because the prerequisite old-message state was not established. The probe remains entered but unsent.
❌
4: Latest messages disappears after jumpNot verified. No qualifying send-and-jump occurred; tiny-scroll and pill-click behavior were not tested. No cause is inferred.
❌

view run

MelvinBot avatar Nov 04 '26 23:11 MelvinBot

Proposal

What is the root cause of that problem?

Probable stale tracking; medium confidence, not reproduced. List replacement preserves historical scroll state; content-size callbacks can restore the pill.

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

Reconcile offset, threshold and pill only after the loaded newest list reports bottom positioning. Retain pending work otherwise. Scope readiness/enablement retries to live-tail jumps, excluding REPORT_PREVIEW.

Test absent scroll events, delayed readiness, mount restoration and upward scrolling.

Evidence and offending-PR investigation

Web reproduction remained blocked; no parent-versus-merge comparison establishes an offender.


Next Steps for Contributor+ team: To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/106015) to create a draft PR. To refine: @MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.


view run · view recording

MelvinBot avatar Nov 04 '26 23:11 MelvinBot

Problem: Opening a chat via a deep link to an older message shows the "Latest messages" pill, as expected. Sending a new message jumps the list to the newest messages at the bottom, but the pill stays visible even though the user is already at the latest messages.

Root cause: The live-tail jump in useReportActionsNewActionLiveTail.ts clears the linked action param, which changes listID and remounts InvertedFlashList at the bottom — but ActionListContext's scrollOffsetRef lives above the list, so it still holds the stale deep-link offset (above ACTION_VISIBLE_THRESHOLD). When the remounted list fires onContentSizeChange, trackVerticalScrolling(undefined) runs updatePillVisibility() without updating scrollOffsetRef, so it reads the stale offset and re-shows the pill that the jump had just hidden. No subsequent native onScroll fires (the list is already at offset 0), so the stale offset is never corrected.

Fix: In flushPendingScrollToBottom (src/hooks/useReportActionsScroll.ts), when flushing the pending scroll to the bottom, reset scrollOffsetRef.current = 0 and call setIsFloatingMessageCounterVisible(false) before scrolling, so the pill state matches the actual bottom position and later onContentSizeChange calls see offset 0 instead of the stale deep-link offset. This single point covers both deep-link remount jumps and in-place live-tail jumps, since both go through this flush.

Verification: Deep-link to an older message, send a message, and confirm the pill disappears and stays disappeared; scroll up afterwards and confirm the pill reappears only on genuine upward scroll; confirm normal (non-deep-linked) live-tail jumps are unchanged. Add a test for the deep-link send flow asserting the pill is hidden after the flush and scrollOffsetRef is 0.

khizzcr7 avatar Nov 05 '26 00:11 khizzcr7

@MelvinBot Investigate this issue and write-up a new formal proposal. Find the offending PR if possible (either the latest staging deploy checklist or older).

ikevin127 avatar Nov 05 '26 00:11 ikevin127

🤖 Web test steps verification results: ⚠️ partial

Onboarding completed on dev NewDot web. Reproduction was blocked while obtaining a genuine message permalink; product behavior remains unverified.

Current session end state after permalink setup was blocked
Step Status
VERIFY1: Authenticated app opensCompleted onboarding. Authenticated Home, Inbox, and self-chat rendered.
✅
VERIFY2: Genuine old-message deep link with newer messages offscreen and Latest messages visibleBlocked, not a product failure. Created a self-chat anchor message, but obtained no genuine permalink. Required state remains unverified.
Current session end state after permalink setup was blocked
❌
VERIFY3: Sending reveals newest and sent messageUnverified: required deep-link precondition was not established.
❌
VERIFY4: Latest messages pill disappearsUnverified: required precondition was not established. Tiny-scroll/pill-click correction was not tested.
❌

view run

MelvinBot avatar Nov 05 '26 01:11 MelvinBot

Proposal

Updated November 5, 2026: Corrected based on feedback from ikevin127.

What is the root cause of that problem?

The saved scroll offset stays at the historical deep-link position after the list jumps to the newest messages, confirmed by ikevin127’s local reproduction and logging. Subsequent content-size callbacks reuse that stale offset and show the “Latest messages” pill again.

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

In flushPendingScrollToBottom, immediately after reportScrollManager.scrollToBottom():

  1. Set scrollOffsetRef.current = 0.
  2. Call setIsFloatingMessageCounterVisible(false).

Keep the existing enabled guard, pending-scroll reset and pagination-pruning call unchanged. Add the explanatory comment about remounted live-tail lists not emitting a correcting scroll event. No offset accessor, shared-ref type changes, onLoad reconciliation or additional scheduling changes are needed for this fix.

Code references and regression test

This is the revised implementation/test plan; no source changes or new test execution are claimed here. The introducing PR remains unconfirmed; the previously checked key-boundary history is unchanged.


Next Steps for Contributor+ team: To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/106015#issuecomment-6646814996) to create a draft PR. To refine: @MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.

MelvinBot avatar Nov 05 '26 01:11 MelvinBot

@MelvinBot Root cause confirmed: I reproduced it locally and logged scrollOffsetRef staying at the deep-link offset through the whole jump. Update your proposal to go with the simpler fix instead of the offset accessor. scrollToBottom is a non-animated scrollToIndex({index: 0}), and the flush only runs from the list's own onLayout/onContentSizeChange, so 0 is the real position at that point:

const flushPendingScrollToBottom = () => {
    if (!isScrollToBottomEnabled) {
        return;
    }
    reportScrollManager.scrollToBottom();
    // A list remounted for the live tail already sits at the bottom, so no scroll event corrects the offset left
    // by the linked message. Sync it here, or the next content size change shows the Latest messages pill again.
    scrollOffsetRef.current = 0;
    setIsFloatingMessageCounterVisible(false);
    setIsScrollToBottomEnabled(false);
    completeLiveTailPruneAfterScrollToBottom();
};

Add a case to the flushPendingScrollToBottom block in tests/unit/useReportActionsScrollTest.tsx: a stale offset above the threshold, flush, then assert the offset is 0 and the pill was hidden.

ikevin127 avatar Nov 05 '26 04:11 ikevin127

Updated the proposal in place using your confirmed reproduction.

  • Reset the saved offset to 0 and hide the pill immediately after scrollToBottom(), preserving the guard and pruning logic.
  • Removed the offset-accessor/onLoad approach.
  • Specified the regression case: start above the threshold, flush, then assert offset 0 and the pill setter called with false.

This updates the proposal and test plan only; no source changes or new tests were run.


view run

MelvinBot avatar Nov 05 '26 04:11 MelvinBot

@MelvinBot updated proposal LGTM.

🎀👀🎀 C+ reviewed

ikevin127 avatar Nov 05 '26 06:11 ikevin127

Triggered auto assignment to @NicolasBonet, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] avatar Nov 05 '26 06:11 melvin-bot[bot]