Fix console error when opening a newly created expense on the Spend page#95670
Fix console error when opening a newly created expense on the Spend page#95670MelvinBot wants to merge 1 commit into
Conversation
Co-authored-by: DylanDylann <DylanDylann@users.noreply.github.com>
|
I created this PR from an upstream branch since I don't have push access to your fork. To take ownership of this branch and be able to push updates, run: Then you can close this PR and open a new one from your fork. |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
Per MelvinBot policy I can't tick the author checklist or fill out the human Every code-relevant check is green. I verified the two most likely to catch this change locally against the changed file (
All other CI jobs are passing. When I finished, The failing check log |
|
@MelvinBot Ready to review |
ReviewVerdict: The code change is correct, minimal, and the root-cause reasoning holds up — the render-phase → commit-phase move is the right fix for this warning. No functional regression. Two non-code items still block merge (see below); I can't complete them myself. Why the fix is correctThe warning fires because I verified the supporting claims:
Blockers before this can merge
Every code-relevant check is green (ESLint + typecheck verified locally earlier). Once the checklist/Tests/QA are filled in, this looks good to go from a code standpoint. |
|
@MelvinBot Mark the PR ready |
|
@DylanDylann 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] |
|
Done — PR #95670 is now marked Ready for review. ✅ One heads-up: the |
|
The failing ESLint check is not related to this PR — it's a pre-existing Why it's unrelated: This PR only touches
Both files have the exact same violation counts on Merging latest Recommended fix (belongs on EvidenceThe other failing check, PR Author Checklist / |
|
@MelvinBot Got a failed Eslint check |
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
|
The failing ESLint check is not caused by this PR — it's a broken- What's failing: the seatbelt rule in Root cause: a recent revert on Already being fixed: #95671 — "Fix ESLint seatbelt budget violations reintroduced by revert." Once that lands on I'm not pushing anything here: the fix belongs on Evidence
|
Explanation of Change
Fixes the dev-only console error
Cannot update a component (SearchPage) while rendering a different component (Search)that appears when opening a newly created expense on the Spend page.Searchbails out to an error/empty state via conditionalreturns during render (searchResults === undefined,hasErrors, and the empty-state branch). Each of those callscancelNavigationSpans(), which — before this change — also called the parent-ownedonContentReady?.()(SearchPage'ssetIsSearchReady(true)fromuseSearchOverlay). Updating the parent's state duringSearch's render is exactly what React's warning flags.When a just-created expense is opened before its transaction lands in the search snapshot,
Searchtransiently takes the empty-state bail-out, so the render-phase parent update fires and the warning is logged.The fix moves the
onContentReady?.()call out ofcancelNavigationSpansand into the existing no-dependency post-commituseEffect(guarded by thedidBailToFallbackStateref that the bail-out paths already set). This defers the parent update to the commit phase instead of during render, matching the flush pattern already used in the same file.setIsSearchReady(true)is idempotent, so firing it on every bail-out render is safe and does not loop. Behavior is otherwise unchanged.Fixed Issues
$ #94318
PROPOSAL: #94318 (comment)
Tests
// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review"
// Please describe what tests you performed that validates your changed worked.
Offline tests
Same as Tests.
QA Steps
// TODO: The human co-author must fill out the QA tests you ran before marking this PR as "ready for review".
// Please describe what QA needs to do to validate your changes and what areas do they need to test for regressions.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, 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.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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari