Skip to content

Keep report navigation page 2 when Next reaches the end of the first … - #104356

Open
yusufdeveloper2903 wants to merge 15 commits into
Expensify:mainfrom
yusufdeveloper2903:fix/101453-report-navigation-next-page
Open

yusufdeveloper2903 wants to merge 15 commits into
Expensify:mainfrom
yusufdeveloper2903:fix/101453-report-navigation-next-page

Conversation

@yusufdeveloper2903

@yusufdeveloper2903 yusufdeveloper2903 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Next stopped at "50 of 50" for two reasons:

  1. While a report was open, the Search list behind it refetched page 1 and wiped the page 2 that Next had loaded. While an RHP covers Search, that refetch now waits until Search is focused again (new entries still refetch right away).
  2. The page 2 request waited behind the OpenReport writes that each Next press queues. It now uses skipWaitForWrites: true.

Fixed Issues

$ #101453
PROPOSAL: #101453 (comment)

Tests

Precondition: account with more than 50 expense reports.

  1. Go to Spend > Reports and open the first report.
  2. Press Next quickly up to report 50.
  3. Verify Next is enabled and pressing it opens report 51.
  • Verify that no errors appear in the JS console

Offline tests

  1. Open a report from Spend > Reports and go offline.
  2. Press Next and verify it moves between the loaded reports.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

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

…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>
@yusufdeveloper2903
yusufdeveloper2903 requested review from a team as code owners October 19, 2026 13:52
@melvin-bot
melvin-bot Bot requested review from marufsharifi and removed request for a team October 19, 2026 13:52
@melvin-bot

melvin-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

@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]

@melvin-bot
melvin-bot Bot requested review from joekaufmanexpensify and removed request for a team October 19, 2026 13:52
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T13:29:50.870856Z 72cb205 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@yusufdeveloper2903 yusufdeveloper2903 changed the title Keep report navigation page 2 when Next reaches the end of the first … [WIP] Keep report navigation page 2 when Next reaches the end of the first … Oct 19, 2026
@marufsharifi

Copy link
Copy Markdown

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@marufsharifi

Copy link
Copy Markdown

BUG#1:

RF-1.mp4

@marufsharifi

Copy link
Copy Markdown

BUG#2:

RF-2.mov

@marufsharifi

Copy link
Copy Markdown

@yusufdeveloper2903, could you please check the above bugs and comment. thanks.

@yusufdeveloper2903

Copy link
Copy Markdown
Contributor Author

@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.

@yusufdeveloper2903 yusufdeveloper2903 changed the title [WIP] Keep report navigation page 2 when Next reaches the end of the first … Keep report navigation page 2 when Next reaches the end of the first … Oct 20, 2026
@yusufdeveloper2903

Copy link
Copy Markdown
Contributor Author

Both bugs are fixed, and after-fix videos for all platforms are in the PR description. The PR is ready for review.

@joekaufmanexpensify joekaufmanexpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good for product

@marufsharifi

Copy link
Copy Markdown

BUG#1:

RF-1.mp4

@marufsharifi

Copy link
Copy Markdown

BUG#2:

RF-2.mov

@marufsharifi

Copy link
Copy Markdown

@yusufdeveloper2903, please check the above two bugs. thanks.

…igation-next-page

# Conflicts:
#	src/libs/actions/Search.ts
@yusufdeveloper2903

Copy link
Copy Markdown
Contributor Author

@marufsharifi Thanks for testing again! Both bugs are fixed in 1f33f71

@marufsharifi

Copy link
Copy Markdown

checking again. today

@marufsharifi

Copy link
Copy Markdown

BUG#1: Next arrow becomes disabled at 50 of 50, but pagination works after deleting a report and retrying

Precondition: Have more than 50 reports in Spend → Reports.

Steps to reproduce:

  1. Open the app on Chrome.
  2. Navigate to Spend → Reports.
  3. Open a report from the report list.
  4. Repeatedly click the Next arrow to navigate through the reports.
  5. Continue until the counter reaches 50 of 50.
  6. Observe that the Next arrow becomes disabled, preventing further navigation.
  7. Wait several seconds and verify that the counter remains at 50 of 50.
  8. Close the report and return to the report list.
  9. Open another report, delete it, and return to the report list.
  10. Open a report again and repeatedly click the Next arrow.
  11. Observe that the counter updates and navigation continues beyond report 50.

Expected result:
The Next arrow should remain available when additional reports exist. The app should load more reports automatically and allow navigation beyond report 50 without requiring the user to delete a report or restart navigation.

Actual result:
During the first attempt, rapidly clicking the Next arrow causes navigation to stop at 50 of 50. The Next arrow becomes disabled and remains disabled even after waiting several seconds.

Screen.Recording.2026-11-06.at.6.43.48.PM.mp4

@marufsharifi

Copy link
Copy Markdown

BUG#2: Report screen becomes dimmed when navigating beyond report 100 while offline

Precondition: Have more than 100 reports available in Spend → Reports.

Steps to reproduce:

  1. Open the app in Chrome.
  2. Navigate to Spend → Reports.
  3. Open a report around 77 of 112.
  4. Enable Force offline under Settings → About → Troubleshoot.
  5. Repeatedly click the Next arrow to navigate through the available reports.
  6. Continue until the counter reaches 100 of 112.
  7. Observe the report screen while continuing to reports 101, 102, 103, and beyond.
  8. Click the Previous arrow to navigate back below report 100.

Expected result:
Reports should display normally while navigating through locally available reports offline, regardless of whether the report position is below or above 100. The report screen should not unexpectedly become dimmed.

Actual result:
Navigation works normally from report 77 through report 99.

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

@marufsharifi

Copy link
Copy Markdown

BUG#3: Rapidly clicking Next during report navigation unexpectedly opens the “Hmm... it's not here” page

Precondition: Have more than 100 reports in Spend → Reports.

Steps to reproduce:

  1. Open the app in Chrome.
  2. Navigate to Spend → Reports.
  3. Open a report around 87 of 107.
  4. Rapidly click the right Next arrow multiple times to navigate through reports.
  5. Continue navigating beyond report 100.
  6. Observe what happens after reaching approximately 102 of 107.

Expected result:
Rapidly clicking the Next arrow should navigate through the available reports without opening an error page. Each navigation should open the corresponding report successfully.

Actual result:
After repeatedly clicking the Next arrow, navigation advances from 87 of 107 to 102 of 107.

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

@marufsharifi

Copy link
Copy Markdown

@yusufdeveloper2903, please make sure to test your changes before asking for another review. thanks.

@marufsharifi

Copy link
Copy Markdown

@yusufdeveloper2903, any update. thanks.

@marufsharifi

Copy link
Copy Markdown

@yusufdeveloper2903, Gentle bump. thanks.

@marufsharifi

Copy link
Copy Markdown

@yusufdeveloper2903, any update?

@yusufdeveloper2903

Copy link
Copy Markdown
Contributor Author

@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

@yusufdeveloper2903

Copy link
Copy Markdown
Contributor Author

@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 hasMoreResults: false. Opening a report from the list copies that value into the navigation params. Then Search's first-page refresh replaces the snapshot with page 1 (hasMoreResults: true), but nothing updated the params, so Next stayed disabled at 50 of 50. Deleting a report re-ran the search, and the next open copied the fresh value, which is why it worked after that. Fix: when the snapshot has settled on the same page the params point at, the navigation takes hasMoreResults from it. Verified: 1 of 50 → 60 of 100 in the same flow, plus Drafts 1 → 70 of 76. A unit test covers it.

BUG#2 — not caused by the navigation. MoneyRequestReportView wraps the header and the body in OfflineWithFeedback with the report's pendingFields, so offline, a report with a pending change is shown at 50% opacity. I got exactly this look by giving report 101 a pending field: it dims offline both when reached with Next and when opened directly by URL, and 99/100 stay normal. Reports without pending changes render normally offline from 77 to 106. Could you check report_<id>.pendingFields for reports 101–105 in your account?

BUG2-offline-dim-is-pending-change.mp4

@yusufdeveloper2903

Copy link
Copy Markdown
Contributor Author

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 sortBy:from sortOrder:asc from 1 → 106. There was no "not here" page and no skipped or repeated report. The video was recorded right after the offline BUG#2 session, and the report that shows "not here" is 914807698118302. Does opening that report directly from the list also show "not here"? If it does, the report itself is the problem, not the arrows.

BUG3-online-rapid-next.mp4

@Eskalifer1

Copy link
Copy Markdown
Contributor

@codex review

@Eskalifer1
Eskalifer1 requested review from Eskalifer1 and removed request for marufsharifi November 13, 2026 19:51
@Eskalifer1

Copy link
Copy Markdown
Contributor

@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 AGENTS.md describes how to run code-inline-reviewer), and fix what it finds. The PR has gone through several rounds where a fix brought new issues, and a self-review should catch many of those earlier.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +194 to +195
saveLastSearchParams({
...searchParamsBeforeRefetch,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

Copy link
Copy Markdown
Contributor

This PR adds a new Onyx.connectWithoutView call, so I've requested a review from the Onyx performance reviewers (@tgolen, @mountiny, @luacmartins, @chuckdries) — a review from any one of them is enough. Please add a link in your PR description to the Slack discussion where the @frontend-performance team approved using connectWithoutView here.

@yusufdeveloper2903

Copy link
Copy Markdown
Contributor Author

@Eskalifer1 Updates:

  • Merged main, conflicts resolved.
  • Fixed the Codex finding and replied in the thread.
  • Ran the code-inline-reviewer self-review. It found two issues, both fixed in 72cb205 with tests.

@yusufdeveloper2903

Copy link
Copy Markdown
Contributor Author

About the Onyx.connectWithoutView in src/libs/actions/ReportNavigation.ts: it is in an action file, not a component, and it is not a performance workaround. restoreLastSearchParams runs when a failed Search page request settles, and by then the report navigation that sent it may already be unmounted, so useOnyx can't provide the current params. The value is never rendered. It only decides whether the rollback still applies.

@Eskalifer1

Copy link
Copy Markdown
Contributor

@codex review

Comment on lines 139 to +142
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});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +209 to +218
// 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;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +305 to +306
// 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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants