Repository navigation
Keep report navigation page 2 when Next reaches the end of the first … - #104356
yusufdeveloper2903 wants to merge 15 commits into
Conversation
…page The Search list behind the report RHP refetched page 1 whenever opening a report rewrote one of its transactions, and that offset 0 response replaced the snapshot, dropping the page the Next arrow had just loaded. Defer that refetch until Search is focused again, unless the results lack a new entry. The page request also waited behind the OpenReport write each arrow press queues, keeping Next disabled at report 50 until the queue drained. Send it with skipWaitForWrites. Fixes Expensify#101453 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@marufsharifi Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 461d009eac
ℹ️ 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".
|
BUG#1: RF-1.mp4 |
|
BUG#2: RF-2.mov |
|
@yusufdeveloper2903, could you please check the above bugs and comment. thanks. |
|
@marufsharifi Thanks for testing! I'm looking into BUG#1 and BUG#2 now and working on fixes. I'll update the PR and let you know once it's ready for another review. |
|
Both bugs are fixed, and after-fix videos for all platforms are in the PR description. The PR is ready for review. |
joekaufmanexpensify
left a comment
There was a problem hiding this comment.
Good for product
|
BUG#1: RF-1.mp4 |
|
BUG#2: RF-2.mov |
|
@yusufdeveloper2903, please check the above two bugs. thanks. |
…igation-next-page # Conflicts: # src/libs/actions/Search.ts
|
@marufsharifi Thanks for testing again! Both bugs are fixed in 1f33f71 |
|
checking again. today |
BUG#1: Next arrow becomes disabled at 50 of 50, but pagination works after deleting a report and retryingPrecondition: Have more than 50 reports in Spend → Reports. Steps to reproduce:
Expected result: Actual result: Screen.Recording.2026-11-06.at.6.43.48.PM.mp4 |
BUG#2: Report screen becomes dimmed when navigating beyond report 100 while offlinePrecondition: Have more than 100 reports available in Spend → Reports. Steps to reproduce:
Expected result: Actual result: However, around 100 of 112, the entire report screen becomes unexpectedly dimmed, as though a dark overlay is displayed. The dimmed appearance continues while navigating through subsequent reports, including reports 101–105. When navigating backward to report 99, the screen returns to its normal appearance. Screen.Recording.2026-11-06.at.5.30.27.PM.mov |
BUG#3: Rapidly clicking Next during report navigation unexpectedly opens the “Hmm... it's not here” pagePrecondition: Have more than 100 reports in Spend → Reports. Steps to reproduce:
Expected result: Actual result: However, continuing to navigate unexpectedly opens the “Hmm... it's not here” page, which indicates that the report or expense may have been deleted or is inaccessible. The report navigation is interrupted even though the counter previously indicated that additional reports were available. Screen.Recording.2026-11-06.at.6.58.35.PM.2.mov |
|
@yusufdeveloper2903, please make sure to test your changes before asking for another review. thanks. |
|
@yusufdeveloper2903, any update. thanks. |
|
@yusufdeveloper2903, Gentle bump. thanks. |
|
@yusufdeveloper2903, any update? |
|
@marufsharifi Sorry for the delay and for not replying sooner. I'm fixing BUG#1, BUG#2 and BUG#3 now and will have them done today |
|
@marufsharifi Thanks for the detailed steps. I reproduced and checked each one. BUG#1 — fixed. Root cause: after a session reaches page 3, the cached snapshot ends with BUG#2 — not caused by the navigation. BUG2-offline-dim-is-pending-change.mp4 |
|
BUG#3 — couldn't reproduce online. I tried rapid Next from 73 and 85 across the page-3 load (with the Search response delayed by 2.5–6s), and BUG3-online-rapid-next.mp4 |
|
@codex review |
|
@yusufdeveloper2903 I'm taking over as C+ on this PR, so I'll be reviewing it from here. It will take me a while to go through the whole thread and the current branch properly. In the meantime it would speed things up if you reviewed your own changes before each push. Please run a local AI agent review of the diff (the repo's I'm also triggering a Codex review here, so you can start on whatever it reports. Additionally you can trigger codex review yourself as i did in previous comment(Please remember that the agent isn't always right, and sometimes there's no need to correct what they write. For each review from an agent, please add a comment indicating whether you've fixed it or if it doesn't need to be corrected. Thank you!) Once I've gone through the PR in detail I'll come back with my own comments. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5497b2b44b
ℹ️ 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".
| saveLastSearchParams({ | ||
| ...searchParamsBeforeRefetch, |
There was a problem hiding this comment.
Guard backfill rollback against a changed active search
If a backfill is still pending when the user closes this RHP and opens another search/report, a late failure unconditionally restores the captured query into the global REPORT_NAVIGATION_LAST_SEARCH_QUERY. This overwrites the newer parameters saved by useSearchPageSetup or the newly opened report, making its carousel subscribe to and paginate the old search. Check that the current query and cursor still belong to the failed request before rolling back; the searchParamsBeforeRequest rollback below needs the same protection.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9766d48. Both rollbacks now go through restoreLastSearchParams, which restores the params only while they still point at the failed request (same query hash and offset). If the user moved on to another search or another page before the failure arrived, the newer params are kept. Covered by tests/actions/ReportNavigationTest.ts.
…igation-next-page
…to the failed page request
…rred refetch when nothing changed
|
This PR adds a new |
|
@Eskalifer1 Updates:
|
|
About the |
|
@codex review |
| const [isSearchLoading = false] = useOnyx(`${ONYXKEYS.COLLECTION.SNAPSHOT}${lastSearchQuery?.queryJSON?.hash}`, {selector: searchLoadingSelector}); | ||
| const [snapshotOffset] = useOnyx(`${ONYXKEYS.COLLECTION.SNAPSHOT}${lastSearchQuery?.queryJSON?.hash}`, {selector: searchOffsetSelector}); | ||
| const [snapshotHasMoreResults] = useOnyx(`${ONYXKEYS.COLLECTION.SNAPSHOT}${lastSearchQuery?.queryJSON?.hash}`, {selector: searchHasMoreResultsSelector}); | ||
| const [isSnapshotPending = false] = useOnyx(`${ONYXKEYS.COLLECTION.SNAPSHOT}${lastSearchQuery?.queryJSON?.hash}`, {selector: searchPendingSelector}); |
There was a problem hiding this comment.
Four useOnyx calls now subscribe to the same snapshot_<hash> key, and searchPendingSelector repeats searchLoadingSelector plus one more condition. A single selector returning these fields would keep one subscription.
| // With an RHP over Search, only an entry the user just created there needs a refetch right away. Opening a report | ||
| // also writes transactions the results lack (split originals, expenses of reports on pages not loaded yet), and | ||
| // refetching from offset 0 replaces the snapshot, dropping the pages the report navigation arrows loaded. Defer | ||
| // everything else until Search is focused again. | ||
| const hasCreatedNewID = isChat ? hasAGenuinelyNewID : createdTransactionIDs.some((id) => !existingSearchResultIDsSet.has(id)); | ||
| if (!isFocused && !hasCreatedNewID) { | ||
| hasPendingSearchRef.current = true; | ||
| return; | ||
| } | ||
|
|
There was a problem hiding this comment.
The deferral applies to any change under an RHP that is not a newly created entry, not only to the paging case. Editing an expense already in the results, approving or submitting a report, or deleting an expense now leaves the Search list and the footer total stale until the RHP closes, where the base refetched right away.
| // On the last loaded report, Next only requests the next page. Wrapping around would jump back to the first report. | ||
| goToReportId(effectiveAllReports.at(currentIndex + 1)); |
There was a problem hiding this comment.
When the last loaded report is open and hasMoreResults is true, Next stays enabled but does nothing if search() returns early (offline, isLoading, or an in-flight request for the same offset). The wraparound is gone, so at(currentIndex + 1) is undefined and the press has no effect or feedback.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 72cb205654
ℹ️ 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".
| searchKey: lastSearchQuery.searchKey, | ||
| isLoading: isSearchLoading, | ||
| skipWaitForWrites: true, | ||
| shouldShowLoading: false, |
There was a problem hiding this comment.
Serialize Next pagination with pending backfills
When a first-page refresh leaves the saved offset at 100 with hasMoreResults=true, this recovery requests offset 50 while leaving isSearchLoading=false. Pressing Next near report 40 then lets goToNextReport() request offset 150 from the saved cursor, although offset 50 is still pending and offset 100 has not been recovered. If offset 150 returns first, its reports enter the navigation list before the missing pages, so Next from the last report on page one can jump directly to report 151 instead of report 51. Gate arrow-initiated page requests on isSnapshotPending and the remaining recovery gap so navigation cannot append noncontiguous pages.
Useful? React with 👍 / 👎.
| return; | ||
| } | ||
|
|
||
| if (!isSnapshotPending && snapshotOffset !== undefined && (lastSearchQuery.offset ?? 0) > snapshotOffset) { |
There was a problem hiding this comment.
Stop backfill when the refreshed results are exhausted
If payments, approvals, or removals shrink the matching results below the previously saved cursor, snapshotHasMoreResults can become false while this condition remains true. Recovery nevertheless requests another page and continues chasing the old offset even after responses indicate that no further results exist. A previously deeply paginated search can therefore generate a chain of empty network requests without further user pagination. Stop recovery at the first exhausted page and reconcile the saved offset and hasMoreResults with that page.
Useful? React with 👍 / 👎.
| // Given Next loaded page 2 (the last one), then Pay refetched the first page, which replaced the snapshot | ||
| jest.mocked(search).mockClear(); | ||
| jest.mocked(saveLastSearchParams).mockClear(); | ||
| renderNavigationOnFirstPage('40', {offset: CONST.SEARCH.RESULTS_PAGE_SIZE, hasMoreResults: false}, {offset: 0, hasMoreResults: true}); |
There was a problem hiding this comment.
Document the When phase in the new backfill tests
This test and several other new first page refetch tests have // Given and // Then sections but omit // When. Root AGENTS.md explicitly requires all three comments for every test case. Separate the setup from the render or refresh action with a // When comment explaining why that transition is being exercised.
AGENTS.md reference: AGENTS.md:L93-L93
Useful? React with 👍 / 👎.
Explanation of Change
Next stopped at "50 of 50" for two reasons:
OpenReportwrites that each Next press queues. It now usesskipWaitForWrites: true.Fixed Issues
$ #101453
PROPOSAL: #101453 (comment)
Tests
Precondition: account with more than 50 expense reports.
Offline tests
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)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.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
android-native-after.mp4
Android: mWeb Chrome
android-chrome-after.mp4
iOS: Native
ios-native-after.mp4
iOS: mWeb Safari
ios-safari-after.mp4
MacOS: Chrome / Safari
web-after.mp4