[$250] Chat - Opening a room at its oldest unread message never loads newer messages, so the newest messages stay hidden while the LHN shows them
Version Number: 9.5.21-0 Reproducible in staging?: Unknown Reproducible in production?: Yes Email or phone of affected tester (no customers): Internal (@mallenexpensify) Issue reported by: @mallenexpensify Bug source: Internal Device used: MacOS desktop app App Component: Chat Report View
Action Performed
- Leave a busy room unread overnight while the desktop app is asleep and the session token expires.
- Wake the computer and open the room from the LHN right away.
No reliable reproduction steps are confirmed yet. This was seen once on 2026-10-27.
Expected Result
The chat shows every message up to the newest one, the same as the LHN preview. If the first page doesn't reach the newest message, the app loads newer messages.
Actual Result
- The LHN preview shows the newest message, from 7:00 AM PDT.
- The chat view stops at the 6:33:30 AM PDT message.
- The 3 newer messages never show.
- The room is still marked as read.
- There are no errors in the console.
Workaround
Not confirmed. Opening another chat and coming back, or using Troubleshoot → Clear cache and restart, should load the missing messages.
Platforms
- [ ] Android: App
- [ ] Android: mWeb Chrome
- [ ] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [ ] Windows: Chrome
- [x] MacOS: Desktop
Screenshots/Videos
Screenshot to be added in a comment.
Analysis
Server timeline (2026-10-27, UTC)
| Time | Command | Result |
|---|---|---|
| 15:12:24.887 | ReconnectApp |
407, token expired |
| 15:12:25.221 | Authenticate |
200 |
| 15:12:26.651 | ReconnectApp (retry) |
200 |
| 15:12:28.322 | OpenReport reportID: 6549335221793525, useLastUnreadReportAction: true, clientLastReadTime: 2026-10-27 01:30:42.130 |
200 |
| 15:13:01.215 | ReadNewestAction reportID: 6549335221793525 |
200 |
Between 15:12 and 15:40 there was no GetNewerActions call. GetOlderActions was called twice.
View in VMUI (internal)
Client state (Onyx export after the bug)
report_6549335221793525
lastVisibleActionCreatedis14:00:01.032, which the LHN uses.lastReadTimeis15:13:00.895.
reportActions_6549335221793525 holds all of these actions:
| reportActionID | created (UTC) | In page? |
|---|---|---|
4369863963592747393 |
13:33:30.106 | yes (newest in page) |
7846867715777742571 |
13:33:42.558 | no |
2600890658472547730 |
13:42:31.609 | no |
6933217277101093990 |
14:00:01.032 | no |
reportActionsPages_6549335221793525
- One page of 162 IDs, from
4369863963592747393to6279233242973018197. - The page has no
-1newest-end marker. - This is the only report out of 49 with pages that is missing the marker.
Likely cause
OpenReportwithuseLastUnreadReportActionreturns a page that starts at the oldest unread message. When a room has many unread messages, that page doesn't reach the newest one, so it has no-1marker.- The 3 newer actions reached Onyx some other way, most likely from the
ReconnectAppretry. They aren't in any page, sogetContinuousChainleaves them out. - The client never calls
GetNewerActions. One possibility is that because those actions are already in Onyx, the list believes it's at the newest message. This needs confirming in the code. ReadNewestActionmarks the room read even though the newest messages aren't shown.
Questions
- How does the report view decide whether it has newer actions after a linked or unread-based
OpenReport? Does it count actions that are stored but not in a page? - Should actions that arrive through
ReconnectAppor Pusher be merged into the page when the page doesn't reach the newest message? - Should
ReadNewestActionwait until the newest action is actually shown?
Related: https://github.com/Expensify/App/issues/104900, which has the same trigger (wake + expired token → 407 → reauth). Reauthentication worked here, so this is a separate bug. Also https://github.com/Expensify/App/issues/99214, which has a similar symptom, but there the message never reached the client.
🤖 Generated with Claude Code
Issue Owner
Current Issue Owner: @marcaaronUpwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022122878351777980870
- Upwork Job ID: 2122878351777980870
- Last Price Increase: 2026-11-18
Checking with C+ to see if they can repro
- https://expensify.slack.com/archives/C02NK2DQWUX/p1793143461137159
Looks like related to our ongoing PR https://github.com/Expensify/App/pull/104433, @mukhrr wdyt?
@eh2077 hmmm.. GetNewerActions stops firing at the newest end. Nothing is rewound and all actions are in Onyx, just not in the page, so I dont think its related to #104433
Meanwhile I able to reproduce this bug with following steps:
Steps
- Use two accounts, A (reader) and B (sender), in separate browsers.
- B starts a DM with A and sends one message. A opens the DM, then goes to Inbox.
- A closes the tab completely.
- B sends about 200 messages into the DM. Short ones are fine ("1", Enter, "2", Enter...) (or use console script to send once)
- A opens the app and waits about 10 seconds on Inbox.
- A opens the DM.
- A scrolls to the bottom of the chat and keeps scrolling.
Expected result
The chat loads newer messages until it reaches B's last message, the same one the LHN preview shows.
Actual result
- The chat opens at B's first unread message, loads a page or two, then stops partway.
- The LHN preview shows B's last message.
- The DM is already marked read.
- More scrolling at the bottom loads nothing.
- Scrolling up until older messages load, then back down, loads one more page and stops again.
https://github.com/user-attachments/assets/a95bb6cc-5808-4300-ba7d-78c34f14c29e
@eh2077 can you pls try also?
Meanwhile I able to reproduce this bug with following steps:
Steps
- Use two accounts, A (reader) and B (sender), in separate browsers.
- B starts a DM with A and sends one message. A opens the DM, then goes to Inbox.
- A closes the tab completely.
- B sends about 200 messages into the DM. Short ones are fine ("1", Enter, "2", Enter...) (or use console script to send once)
- A opens the app and waits about 10 seconds on Inbox.
- A opens the DM.
- A scrolls to the bottom of the chat and keeps scrolling.
Expected result
The chat loads newer messages until it reaches B's last message, the same one the LHN preview shows.
Actual result
- The chat opens at B's first unread message, loads a page or two, then stops partway.
- The LHN preview shows B's last message.
- The DM is already marked read.
- More scrolling at the bottom loads nothing.
- Scrolling up until older messages load, then back down, loads one more page and stops again.
105204-before-web.mp4 @eh2077 can you pls try also?
@eh2077 kindly bump
@mallenexpensify Still overdue 6 days?! Let's take care of this!
Hard to reproduce
@mallenexpensify 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
@mallenexpensify Huh... This is 4 days overdue. Who can take care of this?
@mukhrr , assigning you as C+, for once you've been onboarded.
@mallenexpensify thanks. I think I am not able to have Melvin to propose a fix yet. but let me try at least.
@MelvinBot can you try to reproduce based on this and give a proposal?
@MelvinBot can you try to reproduce based on this and give a proposal?
@MelvinBot can you try to reproduce based on https://github.com/Expensify/App/issues/105204#issuecomment-6462959439 and give a proposal?
🤖 Web test steps verification results: ❌ fail
The reproduction was blocked: this test environment supports only one pinned browser session, but the documented steps require two accounts in separate browsers and closing/reopening the reader’s tab. No product failure was confirmed, and no screenshots were captured.
| Step | Status |
|---|---|
1. Open reader A and sender B in separate browsersA second account/browser session is unavailable. |
❌ |
2. Send an initial DM; A opens it and returns to InboxNot executed because the two-account setup was blocked. |
❌ |
3. Close A’s tab completelyNot executed; manually closing the pinned session is unsupported. |
❌ |
4. B sends about 200 messagesNot executed because a separate sender session is unavailable. |
❌ |
5. A reopens the app and waits 10 seconds on InboxNot executed because the prerequisites were blocked. |
❌ |
6. A opens the DMNot executed because the required conversation was not created. |
❌ |
7. Scroll repeatedly; compare chat, LHN preview, and read stateNot executed. The pagination stall and premature read state remain unverified. |
❌ |
Preliminary proposal — code-supported hypothesis, not a confirmed fix
Proposal
What is the root cause of that problem?
Not confirmed. The strongest candidate is that the list’s “load newer” callback stays latched after loading a page. This could explain why scrolling farther down does nothing, but scrolling away and back permits another page.
Supporting evidence:
- Unread pagination displays a continuous page around the unread anchor.
- Pagination boundary detection uses page markers. Newer actions merely existing in the cache do not make an anchored page complete.
- The chat list loads newer messages through
onStartReached. FlashList’s implementation rearms that callback when the viewport leaves its threshold, but does not reset its start latch when data changes.
The premature read state remains unexplained: current automatic mark-as-read paths already check for unloaded newer actions.
What changes do you think we should make in order to solve the problem?
First confirm that the callback remains latched during the reported stall. If confirmed, rearm newer-page loading when its leading boundary advances, without requiring scrolling away and back. Preserve duplicate-request protection.
Regression coverage should verify multiple consecutive newer pages, reaching the newest message without leaving the bottom, and keeping the report unread while newer messages remain unloaded.
What alternative solutions did you explore? (Optional)
Do not merge all cached messages into the displayed page or manufacture a newest-end marker: cached messages do not establish continuity.
Blocker: a two-account reproduction with callback/scroll-state capture is still needed before treating this as an implementation-ready proposal.
well thanks, Matt. I think we need to open this for contributors.
[!NOTE] Only proposals with before/after videos are reviewed to be sure if they really work
🆘 C+ Help Wanted
🚨 Edited by proposal-police: This proposal was edited at 2026-11-18 04:38:46 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a chat opens in the middle of its history (oldest unread or a linked message) and the user scrolls to the bottom of what's loaded, newer messages stop loading after a page or two, so the newest messages stay hidden while the LHN shows them.
What is the root cause of that problem?
In the inbox chat, newer messages are only ever requested from the list's onStartReached
https://github.com/Expensify/App/blob/bad5f3d3fb722578f151bedf622774ea9c49e8f4/src/pages/inbox/report/ReportActionsList/useReportActionsListScroll.ts#L164-L175
https://github.com/Expensify/App/blob/bad5f3d3fb722578f151bedf622774ea9c49e8f4/src/pages/inbox/report/ReportActionsList/useReportActionsListScroll.ts#L199-L200
FlashList fires onStartReached only once each time the offset enters the start zone (0.75 * viewport here). It sets pendingStartReached and only clears it when the offset leaves the zone again. Unlike pendingEndReached, it's never reset when data changes (useBoundDetection.ts#L112-L122, compare with the end reset at #L165-L170):
const isNearStart = lastScrollOffset <= startThresholdDistance;
if (isNearStart && !pendingStartReached.current) {
pendingStartReached.current = true;
onStartReached();
}
pendingStartReached.current = isNearStart;
The only thing that moves the offset out of that zone after a newer page lands is MVCP. But we turn MVCP off while the user is within 250px of the bottom
https://github.com/Expensify/App/blob/bad5f3d3fb722578f151bedf622774ea9c49e8f4/src/hooks/useReportActionsScroll.ts#L203-L214
https://github.com/Expensify/App/blob/bad5f3d3fb722578f151bedf622774ea9c49e8f4/src/pages/inbox/report/ReportActionsList/ReportActionsListContent.tsx#L131
So with the user at the bottom of the loaded chunk:
onStartReachedfires once,GetNewerActionsloads a page- the page is added below with MVCP off, so the offset stays ~0, still in the start zone
pendingStartReachedstaystrueandonStartReachednever fires again, even thoughhasNewerActionsis stilltrue(the page still has no-1marker)
This is exactly the repro above: "loads a page or two, then stops", scrolling more at the bottom does nothing, and scrolling up (offset leaves the zone) and back down loads exactly one more page and stops again.
Our own pagination test only passes the second GetNewerActions because it fakes the MVCP offset jump by hand, scrolling to 500 and back to 0. A real user sitting at the bottom never does that
https://github.com/Expensify/App/blob/bad5f3d3fb722578f151bedf622774ea9c49e8f4/tests/ui/PaginationTest.tsx#L395-L398
I confirmed it in PaginationTest. With the user staying at offset 0 after the first newer page lands, main calls GetNewerActions with cursor 5 and never with cursor 10. The test fails right at the second call.
The original report (no GetNewerActions at all) is the same latch, just taken earlier. On wake the list mounts at the bottom with cached data and fires onStartReached while loadNewerChats still bails out (the cached page still has the -1 marker until OpenReport strips it, or the app is still reconnecting)
https://github.com/Expensify/App/blob/bad5f3d3fb722578f151bedf622774ea9c49e8f4/src/hooks/useLoadReportActions.ts#L102-L114
When the middle-slice OpenReport lands and hasNewerActions flips to true, FlashList is already latched, so nothing asks for the gap. The 3 actions from ReconnectApp stay in Onyx outside any page, and getContinuousChain correctly leaves them out.
What changes do you think we should make in order to solve the problem?
We shouldn't rely on FlashList re-firing onStartReached while the user sits at the newest edge. When there are newer actions and the newer-actions cursor moves (a newer page landed, or OpenReport flipped hasNewerActions to true), and the user is still at the bottom, we request the next page ourselves.
We already auto-load newer pages for money request reports in useMoneyRequestReportPagination
https://github.com/Expensify/App/blob/bad5f3d3fb722578f151bedf622774ea9c49e8f4/src/components/MoneyRequestReportView/useMoneyRequestReportPagination.ts#L79-L101
In useReportActionsListScroll, after loadNewerChatsAfterTransitions:
const [newestFetchedReportActionID] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_PAGINATION_STATE}${reportID}`, {selector: (state) => state?.newestFetchedReportActionID});
const newerPageAutoLoadKey = hasNewerActions ? (newestFetchedReportActionID ?? listData.at(0)?.reportActionID) : undefined;
const lastNewerPageAutoLoadKeyRef = useRef(newerPageAutoLoadKey);
const loadNewerChatsAtBottom = useEffectEvent(() => {
if (hasScrolledOverThreshold) {
return;
}
loadNewerChatsAfterTransitions();
});
useEffect(() => {
if (!newerPageAutoLoadKey || lastNewerPageAutoLoadKeyRef.current === newerPageAutoLoadKey) {
return;
}
lastNewerPageAutoLoadKeyRef.current = newerPageAutoLoadKey;
loadNewerChatsAtBottom();
}, [newerPageAutoLoadKey]);
- it's keyed on the same cursor
loadNewerChatssends (newestFetchedReportActionID), not on the newest rendered row. The page and the pagination state are separate Onyx keys, so the page can render first, and keying on the row resends the old cursor and gets the same page back (I hit this on a real account, it stopped at the 3rd page) - the ref starts at the mount value, so we don't double up the first request that
onStartReachedalready sends on open - it fires once per page that moves the newest edge, and stops once the server says there's nothing newer (
-1marker makeshasNewerActionsfalse), so it can't loop on the same cursor - users who scrolled up (
hasScrolledOverThreshold) keep the normalonStartReachedpath with MVCP loadNewerChatsstill applies its offline/focus guards
Branch with the fix and tests (passes on the fix, fails on main): https://github.com/Expensify/App/compare/main...David-2002065:App:fix/105204-load-newer-at-bottom
Tested on staging with a real room of 300 messages, opening a link to an older message (Update 20) and scrolling to the bottom.
Before (stops at Update 143, no more GetNewerActions):
https://github.com/user-attachments/assets/93c737cf-3e79-4a13-8ec8-c6ddff15a70a
After (loads all the way to Update 300):
https://github.com/user-attachments/assets/bb8a503e-1006-4719-a4bb-76ace7d8aed1
What specific scenarios should we cover in automated tests?
In PaginationTest (GetNewerActions mock returns a list of page sizes, then an empty page meaning newest reached):
- Open a linked chat, stay at offset 0, backend has two more pages. Expect
GetNewerActionswith cursors5,10,15and 15 messages, without any extra scrolling. Fails on main at the10call. - Update the existing "load newer messages" test so it no longer fakes the MVCP scroll. The second call (cursor
10) happens while staying at the bottom, and scrolling away and back once the newest is reached sends no more requests. - Initial and older loading tests stay unchanged and keep passing.
What alternative solutions did you explore? (Optional)
- Keep MVCP on while
hasNewerActionsis true
const shouldMaintainVisibleContentPosition = hasScrolledOverThreshold || shouldFocusToTopOnMount || hasNewerActions;
A newer page added below then pushes the offset out of the start zone and releases the latch, so the next scroll down fires onStartReached. It's one line but the user has to scroll for every page, and it doesn't fix the original report where the latch was taken before hasNewerActions became true, so GetNewerActions would still never be sent there.
- Patch FlashList to reset
pendingStartReachedwhendatachanges, same aspendingEndReached. That fixes it at the source, but it changes every list usingonStartReachedand adds another patch to maintain, so I'd keep it in the report list.
🚨 Edited by proposal-police: This proposal was edited at 2026-11-18 02:33:01 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Opening a room at its oldest unread message can leave the chat permanently stuck at the end of the unread page: the newer messages that exist on the server are never loaded into the view, GetNewerActions is never called, and the room still gets marked as read even though the newest messages were never shown. The LHN preview shows the newest message while the chat view stops at an older one.
What is the root cause of that problem?
Two client-side gaps combine. All of the pagination state in the Onyx export is correct — the failure is that nothing acts on it, and one mark-as-read path ignores it.
1. The chat view requests newer actions only from a one-shot scroll event, so a single swallowed trigger means GetNewerActions is never sent.
OpenReport with useLastUnreadReportAction returns a page that starts at the oldest unread message. When a room has many unread messages, that page does not reach the newest action, so the stored page in reportActionsPages_ correctly has no -1 "synced to newest" marker — the pagination middleware only adds that marker when the server confirms nothing newer exists:
https://github.com/Expensify/App/blob/ad6df9f90c062dbf952dbb56dfd6d29fa1aebc9e/src/libs/Middleware/Pagination.ts#L124-L127
The actions delivered by ReconnectApp are not paginated (the middleware only processes paginated commands), so they sit in reportActions_ without belonging to any page, and getContinuousChain correctly keeps them out of the rendered chain — the gap between the unread page and those actions is not proven contiguous. Because the page's first ID is not the -1 marker, getContinuousChain correctly reports that a newer page can be fetched:
https://github.com/Expensify/App/blob/ad6df9f90c062dbf952dbb56dfd6d29fa1aebc9e/src/libs/PaginationUtils.ts#L451-L456
and the paginated hook exposes that as hasNewerActions:
https://github.com/Expensify/App/blob/ad6df9f90c062dbf952dbb56dfd6d29fa1aebc9e/src/hooks/usePaginatedReportActions.ts#L121-L129
So the view knows newer actions exist. The problem is the trigger side: in the chat report list, loadNewerChats is invoked from exactly one place, the inverted list's onStartReached edge callback:
https://github.com/Expensify/App/blob/ad6df9f90c062dbf952dbb56dfd6d29fa1aebc9e/src/pages/inbox/report/ReportActionsList.tsx#L576-L579
onStartReached is a crossing trigger: it fires when the scroll position enters the bottom region and does not fire again until a fresh crossing happens. Meanwhile loadNewerChats silently returns when any of its guards fail at that instant — screen not focused yet, no newest action yet, hasNewerActions still false because the OpenReport response has not merged yet (a cached page from the previous session can even still carry a stale -1 marker until the response strips it), or a brief offline window right after the device wakes:
https://github.com/Expensify/App/blob/ad6df9f90c062dbf952dbb56dfd6d29fa1aebc9e/src/hooks/useLoadReportActions.ts#L102-L114
When the one firing is swallowed this way, there is no later re-check. The list is already resting at the bottom of the loaded window, no new crossing occurs, and GetNewerActions is never requested — which matches the server timeline: no GetNewerActions between 15:12 and 15:40, while GetOlderActions worked twice, because scrolling up keeps producing fresh onEndReached crossings.
The money-request report view had this same class of bug and solved it with a state-driven effect that keeps loading newer actions whenever hasNewerActions is true after the initial load, guarded by a cursor-advance check so it cannot loop:
https://github.com/Expensify/App/blob/ad6df9f90c062dbf952dbb56dfd6d29fa1aebc9e/src/components/MoneyRequestReportView/useMoneyRequestReportPagination.ts#L79-L101
The chat report view never got an equivalent, so for chats it is possible to sit indefinitely in the state "newer actions exist" with no code path left that will ever fetch them.
2. One mark-as-read path ignores hasNewerActions, so the room is marked read without showing the newest messages.
The automatic mark-as-read paths deliberately refuse to run while newer actions are unloaded — the report-change path:
https://github.com/Expensify/App/blob/ad6df9f90c062dbf952dbb56dfd6d29fa1aebc9e/src/hooks/useMarkAsRead.ts#L270-L287
and the app-visibility path, whose comment spells out the invariant ("newer actions outside the loaded slice would be consumed without ever being seen"):
https://github.com/Expensify/App/blob/ad6df9f90c062dbf952dbb56dfd6d29fa1aebc9e/src/hooks/useMarkAsRead.ts#L314-L319
But when the report-change path skips, it latches a pending read, and the completion path calls readNewestAction with no hasNewerActions guard at all:
https://github.com/Expensify/App/blob/ad6df9f90c062dbf952dbb56dfd6d29fa1aebc9e/src/hooks/useMarkAsRead.ts#L346-L356
That completion is triggered whenever the unread-marker action is visible in the viewport:
https://github.com/Expensify/App/blob/ad6df9f90c062dbf952dbb56dfd6d29fa1aebc9e/src/hooks/useReportActionsScroll.ts#L233-L237
https://github.com/Expensify/App/blob/ad6df9f90c062dbf952dbb56dfd6d29fa1aebc9e/src/pages/inbox/report/useReportUnreadMessageScrollTracking.ts#L166-L169
An unread-anchored open positions the list exactly at that marker, so the marker is on screen, the latched read completes, and ReadNewestAction marks the room read even though the newest messages were never rendered — matching the ReadNewestAction at 15:13:01 in the timeline and the "room is still marked as read" symptom.
What changes do you think we should make in order to solve the problem?
-
Add an auto-load-newer convergence loop to the chat report list, modeled on the one the money-request view already uses, as a small dedicated hook called from the list's scroll/pagination hook that wires
onStartReached. While the list rests at its newest edge,hasNewerActionsis true, the screen is focused, the device is online, the initialOpenReportis no longer pending and noGetNewerActionsrequest is in flight, callloadNewerChats. It re-runs whenever any of those inputs or the newer-actions cursor change, so a skippedonStartReachedis retried as soon as the condition that swallowed it clears (e.g. theOpenReportresponse strips the stale-1marker, or the device comes back online). Each cursor is requested at most once (onStartReachedgoes through the same recorder), so a response that doesn't advance the cursor can't cause a request loop and the edge event and the effect don't double-request. To support this,loadNewerChatsreturns whether it actually sent a request anduseLoadReportActionsexposes the cursor it sends, the same way it already exposes theloadOlderChatscursor. Gating on the newest edge (the sameACTION_VISIBLE_THRESHOLDthe list already uses for "scrolled to end") keeps a deep link far back in history from paging through everything newer on its own; it only converges while the user is at the end of the loaded window, which is exactly where the newest messages should be. -
Make the latched-read completion respect the same invariant the automatic paths already enforce. In
useMarkAsRead, havecompleteSkippedMarkAsReadkeep the pending read latched whilehasNewerActionsis true instead of callingreadNewestActionimmediately. Loading the gap clearshasNewerActionswithout any scroll or viewability event, so also add a small effect that completes the held read whenhasNewerActionsflips to false while the list is scrolled to the end and the screen is focused. The room is then marked read only after the newest message is actually in view. The explicit user flows are unaffected: the "newest messages" pill already routes through a live-tail jump (openReport) when the newest action is not loaded, and only marks read directly when the newest action is already rendered.
Both changes are web/desktop/native-shared hook code; no backend change is needed, and ReadNewestAction semantics stay intact.
Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/105204-auto-load-newer-chat-actions?expand=1
What alternative solutions did you explore? (Optional)
-
Merging
ReconnectApp- or Pusher-delivered actions into the stored page when the page does not reach the newest message. Rejected: those actions are separated from the fetched page by a gap of unknown contents, and treating them as contiguous would silently hide the gap messages — the pagination merge code explicitly refuses index-based continuity for exactly this reason. In this incident that would have rendered the room as fully caught up while 162 messages were missing. -
Making the list re-fire
onStartReachedafter data changes, or callingloadNewerChatsunconditionally on mount. Rejected: it depends on list-library edge-event internals, still races theOpenReportresponse (the same guards can swallow the retry), and does not fix the mark-as-read half. -
Changing the server so
ReadNewestActioncannot advance past actions the client never displayed. Rejected: it requires a backend change, and only the client knows what was actually rendered; the client-side guard already exists on the other mark-as-read paths and just needs to cover the completion path.
Job added to Upwork: https://www.upwork.com/jobs/~022122878351777980870
🤖 ProposalPolice™ is tracking duplicate proposals for this issue using an OpenAI Conversation. This comment stores that Conversation's ID and can be safely ignored.
Proposal
What is the root cause of that problem?
After wake-up the room opens with the stale cached page. That page still has the -1 newest-end marker, so the list thinks it is already at the newest message. OpenReport with useLastUnreadReportAction then replaces it with a middle slice, which flips hasNewerActions to true. Nothing asks for the missing messages at that point. The user sees a chat that ends at 6:33:30 AM, while the LHN shows the 7:00 AM message from lastVisibleActionCreated.
Newer messages are only requested from a scroll-edge event (onStartReached in useReportActionsListScroll.ts). That event fires once, at mount, and loadNewerChats in useLoadReportActions.ts bails out at that moment:
https://github.com/Expensify/App/blob/bad5f3d3fb722578f151bedf622774ea9c49e8f4/src/hooks/useLoadReportActions.ts#L102-L114
The three actions that arrived through the ReconnectApp retry sit in reportActions_ but in no page. getContinuousChain correctly ignores them, so the list has no reason to show them. The result is no GetNewerActions call, which matches the server timeline.
Loading newer actions depends on a one-time scroll event, not on the state "the page has no newest-end marker". The load decision lives in the scroll hook, not in the hook that owns pagination.
What changes do you think we should make in order to solve the problem?
useLoadReportActions.ts,loadNewerChats: it already holds the guards for offline, focus andhasNewerActions. Add an effect in this hook that runs whenhasNewerActionschanges fromfalsetotrue, or when the newest page ID changes whilehasNewerActionsis stilltrue. The effect callsloadNewerChatsonce. This covers the case whereOpenReportlands after the scroll event already fired and bailed. Because the effect lives next to the guards, offline and unfocused cases stay protected.
useEffect(() => {
if (!hasNewerActions) {
return;
}
loadNewerChats();
}, [hasNewerActions, newestPageFirstID]);
-
Make the effect skip the request when
loadNewerChatsalready has a request in flight, using the existing request-in-progress guard. If none exists, track the last requested cursor so the same one is not sent twice. This stops it from duplicating the request thatonStartReachedsends on a normal open. -
Once
GetNewerActionsreturns, the page reaches the-1marker andhasNewerActionsbecomesfalse. The effect then stops. The threeReconnectAppactions are included because the server response merges them into the page.
What alternative solutions did you explore? (Optional)
Merging every action stored in Onyx into the page would hide the gap without proving the messages are continuous. It could also show a chat with missing messages in the middle.
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.