Fix pagination to get missing messages#86114
Conversation
|
Will #85744 (comment) be fixed by this PR? |
@aimane-chnaif is the issue you linked still reproducible? |
yes, native only |
|
@aimane-chnaif I just read the description and saw the recording - it doesn't look like it has the same root cause. Here we have the problem in the IOU report, when there is more than 50 IOUs and messages, so I doubt my PR would solve this |
| return; | ||
| } | ||
| prevNewestFetchedIDRef.current = currentCursor; | ||
| loadNewerChats(true); |
There was a problem hiding this comment.
The useEffect calls loadNewerChats(true) which bypasses all guards (isFocused, isOffline, hasNewerActions). Since enableNewerPagination already removes the reportActionID and one-shot guards, would loadNewerChats(false) be enough here?
There was a problem hiding this comment.
yeah, you're right - thanks for pointing this out!
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
|
||
| // Use the Pusher-safe cursor when available instead of newestReportAction | ||
| // (which may include Pusher-delivered actions like Concierge replies that skip gaps) | ||
| if (newestFetchedReportActionID) { |
There was a problem hiding this comment.
❌ CONSISTENCY-3 (docs)
When newestFetchedReportActionID is provided and the report has a transaction thread (isTransactionThreadReport is true), the early return on line 122 causes getNewerActions to be called only for the main report, silently skipping the transaction thread report. The existing non-cursor path (lines 125-128) correctly handles both the main report and the transaction thread. This inconsistency means money request reports with transaction threads will not fetch newer actions for the transaction thread when using the new cursor.
The newestFetchedReportActionID branch should mirror the existing isTransactionThreadReport logic:
if (newestFetchedReportActionID) {
getNewerActions(reportID, newestFetchedReportActionID);
if (isTransactionThreadReport) {
getNewerActions(transactionThreadReport.reportID, transactionThreadNewestAction?.reportActionID);
}
return;
}Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
newestFetchedReportActionID is only passed by MoneyRequestReportActionsList, which doesn't use transaction threads, so this code path can't be reached.
| transactionThreadReport, | ||
| hasOlderActions, | ||
| hasNewerActions, | ||
| newestFetchedReportActionID: reportMetadata?.newestFetchedReportActionID, |
There was a problem hiding this comment.
❌ CONSISTENCY-3 (docs)
The newestFetchedReportActionID cursor and the auto-load useEffect (lines 409-424) are only added to MoneyRequestReportActionsList.tsx, but ReportActionsView.tsx (line 293) also calls useLoadReportActions without the new cursor parameter and without the auto-load effect. The Pagination middleware writes newestFetchedReportActionID to ReportMetadata for ALL report types, yet only MoneyRequestReportActionsList consumes it. This means the same Pusher-gap pagination bug (where Concierge replies skip gaps) can still occur in regular chat reports rendered through ReportActionsView.
Consider applying the same fix to ReportActionsView.tsx -- pass newestFetchedReportActionID from reportMetadata and add the equivalent auto-load logic. If this is intentionally scoped to money request reports only, add a comment explaining why ReportActionsView does not need this fix.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
this bug only affects money request reports because their backend returns actions in ASC order; regular chats use DESC order and never have this gap
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b145e7cbfb
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
src/libs/Middleware/Pagination.ts
Outdated
| // If the server responds with hasNewerActions: true, strip PAGINATION_START_ID from | ||
| // cached pages so it doesn't survive the merge and incorrectly mark the result as having no newer actions. | ||
| const sanitizedExistingPages = shouldMarkNoNewerActions ? existingPages : existingPages.map((page) => page.filter((id) => id !== CONST.PAGINATION_START_ID)); |
There was a problem hiding this comment.
Only strip start marker when server confirms newer actions
sanitizedExistingPages currently removes PAGINATION_START_ID for any response where shouldMarkNoNewerActions is false, but many pagination responses (notably GetOlderActions) omit hasNewerActions entirely. In that undefined case this code still strips the start sentinel, which makes pagination state report hasNewerActions=true even when we are already at the newest action; this can trigger unnecessary GetNewerActions calls (and auto-fetch churn in MoneyRequestReportActionsList). Restrict this stripping to response.hasNewerActions === true so unknown responses preserve the existing boundary.
Useful? React with 👍 / 👎.
|
I can review this issue and complete the checklist after an hour |
|
typecheck fail unrelated 🤔 |
|
@suneox so now it's ok, or the messages are missing? |
|
and if messages are missing - which ones? I've tested with sending numbers because I would see if I miss the first portion or last or the middle |
The messages are still missing, and I’m running another check on a new report |
@koko57 Here are the results from the new test on a new report. To ensure the messages were sent successfully, I also captured the CleanShot.2026-03-26.at.20.03.12.1.mp4
|
|
@suneox but I see that you added some IOUs in the meantime - can you please share exact steps? Have you added any new expense after sending 53/100? |
My steps are to send a message after each expense is created successfully.
Yes, I also created new expenses from 53 to 100. |
|
@suneox so after EACH expense you are sending a message right? So you have 100 expenses and 100 messages? |
Yes, that’s right — one message per expense |
|
ok, I was able to recreate, working on it |
|
Ok, so that's actually strange what I observed:
So now I see the problem - as OpenReport prioritizes IOUs, all the IOUs are sent in OpenReport with these 16 messages. The cursor (newestFetchedReportActionID) is the newest action from that page so it becomes a cursor - The same for the case @suneox mentions - but this time it shows that GetNewerActions prioritize IOUs, but the effect is the same - the IOU action with the newest timestamp becomes a cursor - so only newer messages are sent back and the 54-99 are missing. However, I think that it's a separate issue and we need to think how to solve it. Seems that prioritizing the IOUs breaks the pagination logic, but I understand we want to prioritize them to properly display the report data, so we should discuss it. But still this PR fixes the original issue when first we create the IOUs and then some messages are sent. @luacmartins what do you think - should we try to fix it here or should we merge this PR and handle this other case separately? |
|
I think we can move forward with the PR since it fixes one class of bugs. We should then fix the edge case in a follow up. |
|
@koko57 TS check is failing again |
Yes, the original scenario works as expected. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppCleanShot.2026-03-27.at.12.20.46.mp4Android: mWeb ChromeCleanShot.2026-03-27.at.12.20.46.3.mp4iOS: HybridAppCleanShot.2026-03-27.at.14.15.27.1.mp4iOS: mWeb SafariCleanShot.2026-03-27.at.12.16.03.2.mp4MacOS: Chrome / SafariFixed CleanShot.2026-03-27.at.12.10.10.1.mp4Fail on latest staging CleanShot.2026-03-27.at.14.18.08.2.mp4 |
|
@luacmartins @suneox all checks pass |
|
I’m still stuck on building the iOS native, so I’ll fix it asap to complete the checklist. |
|
Nice! Gonna merged this one. @koko57 please work on a follow up to fix the edge case above #86114 (comment) |
|
🚧 @luacmartins has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.3.51-0 🚀
Bundle Size Analysis (Sentry): |
|
I reviewed the changes in this PR and confirmed that no changes are required to the help site files under Reasoning: This PR is a purely technical bug fix for internal pagination logic — specifically fixing missing chat messages in expense reports with 50+ transactions. The changes affect:
No user-facing features, UI labels, buttons, settings, or documented workflows were added, removed, or modified. The fix is invisible to end users — reports will simply display all messages correctly. Therefore, no help site documentation updates are needed. |
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.3.51-10 🚀
|



Explanation of Change
Fixed Issues
$ #85647
PROPOSAL: #85647 (comment)
Tests
Prerequisites: Have at least one workspace
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2026-03-25.at.13.48.23.mp4
Android: mWeb Chrome
Screen.Recording.2026-03-25.at.14.25.59.mp4
iOS: Native
Screen.Recording.2026-03-25.at.14.49.24.mp4
iOS: mWeb Safari
Screen.Recording.2026-03-25.at.11.16.29.mp4
MacOS: Chrome / Safari
before:
Screen.Recording.2026-03-24.at.13.23.41.mp4
after:
Screen.Recording.2026-03-24.at.13.44.13.mp4