Skip to content

[CP Staging] Revert "Fix empty view shows briefly when sorting"#97015

Closed
yuwenmemon wants to merge 1 commit into
mainfrom
yuwen-revert-96700
Closed

[CP Staging] Revert "Fix empty view shows briefly when sorting"#97015
yuwenmemon wants to merge 1 commit into
mainfrom
yuwen-revert-96700

Conversation

@yuwenmemon

@yuwenmemon yuwenmemon commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

@mollfpr please review
cc @aimane-chnaif @dmkt9

Explanation of Change

Reverts #96700, which made isSearchDataLoaded recompute the search hash from the (mutable) sortBy/sortOrder snapshot fields instead of comparing directly against queryJSON.hash. During the optimistic empty-report-create flow those fields can be out of sync for a render or two, so the loaded/not-loaded check flips, the stable-data effect in useSearchSnapshot/useStableOptimisticSortedData re-fires every render, and the app hits Maximum update depth exceeded — a hard crash. This is the deploy blocker.

Because #96918 landed on top of #96700 to add null-safety around the same function, GitHub's automatic revert conflicted and couldn't be applied. The sort-hash recompute was undone by hand here while keeping #96918's optional chaining on searchResults.search.

Reverting reintroduces the original cosmetic bug from #96074 (the search results table can flash an empty state for a moment when changing sort) — an acceptable tradeoff against the crash.

Fixed Issues

$ #96946

PROPOSAL: N/A

Tests

  1. Open Settings > Troubleshooting and force offline mode.
  2. Create a new workspace, then delete the workspace that was your default before creating this one.
  3. Create an empty report.
  4. Go back to workspace settings, create another new workspace, and delete the default again.
  5. Create another empty report.
  6. Verify the app does not crash.
  7. Turn network back on, go to Reports, and press a column header to sort.
  8. Confirm the table can briefly show an empty state while re-sorting — this is the known, accepted regression from reverting Fix empty view shows briefly when sorting #96700 (tracked by Spends - Sort function on column briefly show an empty report page #96074).
  • Verify that no errors appear in the JS console

Offline tests

Same as tests — step 1 requires forcing offline mode to reach the pending-write path that crashes.

QA Steps

  1. Open Settings > Troubleshooting and force offline mode.
  2. Create a new workspace, then delete the workspace that was your default before creating this one.
  3. Create an empty report.
  4. Go back to workspace settings, create another new workspace, and delete the default again.
  5. Create another empty report.
  6. Verify the app does not crash.
  • 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 followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and 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 followed the guidelines as stated in the Review Guidelines
  • 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.
  • 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

N/A — revert.

Android: mWeb Chrome

N/A — revert.

iOS: Native

N/A — revert.

iOS: mWeb Safari

N/A — revert.

MacOS: Chrome / Safari

N/A — revert.

This reverts commit 260f0b4, but keeps
the null-safety fix from #96918 by using optional chaining on
searchResults.search in isSearchDataLoaded rather than restoring the
unguarded access.
@yuwenmemon
yuwenmemon requested review from a team as code owners July 25, 2026 00:04
@melvin-bot

melvin-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown

@parasharrajat 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 removed request for a team July 25, 2026 00:04
@github-actions

Copy link
Copy Markdown
Contributor

🚧 yuwenmemon has triggered a test Expensify/App build. You can view the workflow run here.

@aimane-chnaif

Copy link
Copy Markdown
Contributor

@yuwenmemon we can close this. QA team confirmed it's not reproducible anymore.

@yuwenmemon yuwenmemon closed this Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants