You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-07-16] [$250] Spend-"Something went wrong" screen for a failing query flashes #92462
Version Number: 9.3.97-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:https://test-management.browserstack.com/projects/2219752/folder/13176922/test-cases/41237516 Email or phone of affected tester (no customers): N/A Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: iPhone 15 iOS 26.5 App Component: Search
Action Performed:
Sign in to ND
Create a workspace
Go to Spend tab/ Expenses
Type "type:chat category:abcd" in the search field, apply the search
Expected Result:
"Something went wrong" page appears and does not flash
Preliminary analysis — medium confidence. I traced the error-rendering path with code evidence, but the exact frame-timing is iOS-specific (the bug only repros on iOS: App), so the fix below is a strong direction to validate on an iOS build rather than a certainty.
What is the root cause of that problem?
The "Something went wrong" page is FullPageErrorView, and Search renders it whenever the current search snapshot has any errors — that branch is gated only on hasErrors, with no guard for the "request still in flight" state.
The flash happens because searchResults.errors is toggled on every search round-trip: each search() call optimistically clears it (errors: null), and the failure response re-sets it. So as the failing query moves through loading → error (and across any re-render/re-request), the errors key briefly clears and the error page unmounts for a frame before reappearing — the visible flash.
The app already has machinery meant to defer the error UI until the response is confirmed (hasUnresolvedErrors = hasErrors && searchRequestResponseStatusCode === null, which feeds shouldShowLoadingState). But that guard is never applied to the error render branch, and the narrow/mobile page used on iOS never resets searchRequestResponseStatusCode to null at the start of a search — unlike the wide page. So the === null window that's supposed to keep the skeleton up never opens on iOS, which fits the iOS‑App‑only repro.
What changes do you think we should make in order to solve the problem?
In SearchPageNarrow's handleSearchAction, reset searchRequestResponseStatusCode to null before calling search(), matching the wide page.
Gate the error branch so the page renders only after the search settles (i.e. don't render FullPageErrorView while the search is still in its loading/transition state), so the transient clear/loading frames show the skeleton instead of flashing the error page.
Together these aim to make the error page appear once, after the response is confirmed, instead of flickering during the transition.
What alternative solutions did you explore? (Optional)
Keeping the previously-shown error visible during an immediate re-search (instead of optimistically clearing errors) would also remove the flash, but it's more invasive than the gating approach above.
Open question to confirm on an iOS build: what triggers the extra search round-trip (or render) that clears errors mid-flow on iOS. The totals/group retry path doesn't apply to a type:chat query (shouldCalculateTotals/validGroupBy are both false), so the trigger is likely platform render/Onyx-propagation timing. The existing [Search] Showing skeleton log (index.tsx:694) can be used to observe the transition order during a repro.
I also ruled out the canned-query reset effect (index.tsx:1432): it only fires on route / (the reports home) or when shouldResetSearchQuery is set, neither of which applies to a typed query submitted on the /search page.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/92462) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
🚨 Edited by proposal-police: This proposal was edited at 2026-06-03 03:01:17 UTC.
Proposal
What is the root cause of that problem?
The initial search() for a query is issued at the page level by useSearchPageSetup before Search mounts, but Search kept its own mount-time effect that re-issues the same query as soon as it mounts. That call is redundant — Search only ever mounts under SearchPage, keyed by queryJSON.hash, always after the page-level request was already issued.
The redundant call produces both symptoms:
Failing query: the page-level request fails; failureData deletes snapshot.data and writes snapshot.errors. useSearchLoadingState deliberately lets Search mount when errors are present so it can render FullPageErrorView. On mount, the redundant effect re-issues the failing query; its optimisticData sets errors: null, putting the snapshot back to "no data, no errors" → the skeleton replaces the error view → the request fails again → error view → remount → re-issue — an infinite loop of flashing screens and network requests.
Normal query:Search mounts after the first request resolved, so the in-flight dedupe in search() can't catch it → one duplicate API request per search.
What changes do you think we should make in order to solve the problem?
1. Make useSearchPageSetup the single owner of every initial (offset 0) fetch — including the cached-snapshot refresh.
Remove the mount-time handleSearch() from Search. On its own, that removal leaves one gap: on main, the mount-time call also refreshed an already-cached snapshot whenever Search remounted (e.g. flipping Expenses ↔ Reports tabs), which is how rows added/removed elsewhere show up. Onyx mirrors edits to existing snapshot rows automatically, but membership changes need a re-search — pure removal would leave revisited tabs stale.
So the page hook gets a per-instance lastFetchedHashRef tracking the last hash it fetched. Navigating to a hash it hasn't fetched fires search() even when a cached snapshot exists (the refresh main did on remount); dep-driven re-runs for the same hash (load completion, failure, reconnect) are blocked by the ref:
- if (isSnapshotDataLoaded || isSnapshotSearchLoading) {+ if (isSnapshotSearchLoading) {
return;
}
++ // A loaded snapshot only blocks re-runs for the hash we already fetched; navigating (back)+ // to a cached hash still goes through, so it gets the refresh the Search component's+ // mount-time fetch used to provide. Unloaded snapshots can always (re)fire — that keeps+ // the reconnect recovery for queries that never finished loading while offline.+ if (isSnapshotDataLoaded && lastFetchedHashRef.current === hash) {+ return;+ }++ lastFetchedHashRef.current = hash;
const shouldSkipWaitForWrites = hasDeferredWrite(CONST.DEFERRED_LAYOUT_WRITE_KEYS.SEARCH);
Loop-safety, verified against the Onyx writes: failureData keeps search.type/search.status and sets errors, so isSearchDataLoaded treats a failed snapshot as loaded — with the ref blocking same-hash re-runs, nothing re-issues the failed query and the error page renders once and stays. Revisiting a previously failed tab retries it once (a fresh attempt), never loops.
2. Search keeps only the fetches the page hook can't know about, each as its own single-trigger effect — pagination, reconnect refresh, and the totals/grouped retry flag:
- useEffect(() => {- const focusedRoute = findFocusedRoute(navigationRef.getRootState());- const isMigratedModalDisplayed = focusedRoute?.name === NAVIGATORS.MIGRATED_USER_MODAL_NAVIGATOR || focusedRoute?.name === SCREENS.MIGRATED_USER_WELCOME_MODAL.ROOT;-- const comingBackOnlineWithNoResults = prevIsOffline && !isOffline && isEmptyObject(searchResults?.data);- if (!comingBackOnlineWithNoResults && ((!isFocused && !isMigratedModalDisplayed) || isOffline)) {- return;- }-- if (hasPendingWriteOnMountRef.current.hasPendingWriteOnMount && hasDeferredWrite(CONST.DEFERRED_LAYOUT_WRITE_KEYS.SEARCH)) {- return;- }-- if (searchResults?.search?.isLoading) {- if (validGroupBy || (shouldCalculateTotals && searchResults?.search?.count === undefined)) {- shouldRetrySearchWithTotalsOrGroupedRef.current = true;- }- return;- }-- handleSearch({queryJSON, searchKey: currentSearchKey, offset, shouldCalculateTotals, prevReportsLength: filteredDataLength, isLoading: !!searchResults?.search?.isLoading});- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [handleSearch, isOffline, offset, queryJSON, currentSearchKey, shouldCalculateTotals, validGroupBy]);+ // The initial (offset 0) fetch is owned by useSearchPageSetup at the page level — Search only+ // mounts under SearchPage (keyed by queryJSON.hash), after that request has already been issued.++ // Pagination: fetch the next page when fetchMoreResults advances the offset.+ useEffect(() => {+ if (offset === 0 || !isFocused || isOffline || searchResults?.search?.isLoading) {+ return;+ }+ handleSearch({queryJSON, searchKey: currentSearchKey, offset, shouldCalculateTotals, prevReportsLength: filteredDataLength, isLoading: !!searchResults?.search?.isLoading});+ // We don't need to run the effect on change of isFocused or isLoading.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [handleSearch, isOffline, offset, queryJSON, currentSearchKey, shouldCalculateTotals]);++ // Reconnect: refresh the current page when coming back online. Unloaded offset-0 queries are+ // already re-fired on reconnect by useSearchPageSetup, which keeps `isOffline` in its deps.+ useEffect(() => {+ if (!prevIsOffline || isOffline || !isFocused || searchResults?.search?.isLoading) {+ return;+ }+ handleSearch({queryJSON, searchKey: currentSearchKey, offset, shouldCalculateTotals, prevReportsLength: filteredDataLength, isLoading: !!searchResults?.search?.isLoading});+ // Only the offline -> online transition should trigger this refresh.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [isOffline, prevIsOffline]);++ // While a search issued elsewhere is in flight without the totals/grouped data we need,+ // flag it so the existing retry effect below re-queries once it resolves.+ useEffect(() => {+ if (!searchResults?.search?.isLoading) {+ return;+ }+ if (validGroupBy || (shouldCalculateTotals && searchResults?.search?.count === undefined)) {+ shouldRetrySearchWithTotalsOrGroupedRef.current = true;+ }+ }, [searchResults?.search?.isLoading, searchResults?.search?.count, shouldCalculateTotals, validGroupBy]);
fetchMoreResults stays offset-only, so offline load-more behaves like main: scrolling offline only advances the offset, and the pending page fetches once on reconnect.
The two mount-time special cases existed only to serve the redundant call and are deleted with it, with their original jobs verified covered:
3. Companion fix:SearchPageNarrow's handleSearchAction doesn't clear searchRequestResponseStatusCode before re-searching, unlike SearchPage's, so a stale status code can leak into the next request's error state:
Please re-state the problem that we are trying to solve in this issue.
When a search query fails (e.g. type:chat category:abcd, which the backend rejects with INVALID_SEARCH_QUERY), the "Something went wrong" error page does not stay on screen — it flashes/flickers, repeatedly toggling with the loading skeleton instead of rendering stably.
What is the root cause of that problem?
The flash is a self‑perpetuating skeleton ↔ error‑page loop that is unique to failing queries. It comes from three pieces of code interacting:
1. A failed search deletes data from the snapshot.
The failureData for the Search request merges data: null into the snapshot:
In Onyx, merging null for a key deletes it, so after a failure searchResults.data === undefined (not an empty array). A successful search instead sets data to a defined value — this asymmetry is the seed of the bug.
2. The page‑level skeleton gate treats "no data + no errors" as "still loading".
The narrow page chooses between the page skeleton and mounting <Search> (which renders the FullPageErrorView) using useSearchLoadingState:
It returns true (→ show page skeleton, unmount<Search> and its error view) whenever there is no data and no errors. This is reinforced one level up in SearchPage, which only forwards searchResults when there is data or errors, and forwards undefined otherwise:
3. <Search> re‑fires the search every time it mounts — even for an already‑errored query.
When <Search> mounts (which, for a failing query, only happens after the error has arrived), this effect runs and unconditionally calls handleSearch because searchResults.search.isLoading is already false:
<Search>'s mount effect (index.tsx#L704) fires a redundant re‑search → optimistic clears errors to null, data is still undefined → state is now "no data and no errors" → SearchPage forwards undefined / useSearchLoadingState returns true → page skeleton, <Search> unmounts → error page disappears (flash).
The re‑search fails again → errors set → <Search> remounts → its mount effect fires another re‑search → back to step 3 → continuous flashing.
A successful query never flashes because step 2 sets data to a defined value, so the re‑search in step 3 keeps hasNoData === false; <Search> stays mounted and just refreshes in place. The flash is therefore specific to failed queries, exactly as reported.
What changes do you think we should make in order to solve the problem?
Break the loop at its source: do not re‑fire a search for a query whose latest result already errored. There is no value in immediately re‑running a query the server just rejected, and doing so is what clears errors, collapses the state to "no data + no errors", and unmounts the error view.
In src/components/Search/index.tsx, add a hasErrors early‑return to the search‑triggering effect (L704):
useEffect(()=>{constfocusedRoute=findFocusedRoute(navigationRef.getRootState());constisMigratedModalDisplayed=/* ... */;constcomingBackOnlineWithNoResults=prevIsOffline&&!isOffline&&isEmptyObject(searchResults?.data);if(!comingBackOnlineWithNoResults&&((!isFocused&&!isMigratedModalDisplayed)||isOffline)){return;}// The current query already resolved with an error; re-running it here would clear// `errors` optimistically, unmount FullPageErrorView and cause the page to flash// between the skeleton and the error screen. The user can re-submit to retry.if(hasErrors){return;}if(hasPendingWriteOnMountRef.current.hasPendingWriteOnMount&&hasDeferredWrite(CONST.DEFERRED_LAYOUT_WRITE_KEYS.SEARCH)){return;}if(searchResults?.search?.isLoading){/* ...unchanged... */return;}handleSearch({/* ...unchanged... */});// eslint-disable-next-line react-hooks/exhaustive-deps},[handleSearch,isOffline,offset,queryJSON,currentSearchKey,shouldCalculateTotals,validGroupBy,hasErrors]);
The same guard should be applied to the totals/grouped retry effect so it can't re‑search an errored result either:
With this guard, after step 2 above <Search> mounts, the effect sees hasErrors === true and returns without re‑searching. errors is never cleared, the page never swaps back to the skeleton, and the "Something went wrong" screen renders stably — matching the expected result.
Why this is the right layer: the flash is caused by a needless re‑request, not by the rendering logic. Editing the query to something valid still works (that's a new hash → new search triggered by the router submit / queryJSON change with hasErrors === false), and the legitimate offline→online recovery path (comingBackOnlineWithNoResults) is untouched.
Edge cases covered:
Offline:hasErrors is already gated by !isOffline (index.tsx#L435), so offline behaviour is unchanged; the offline error/empty handling and the comingBackOnlineWithNoResults retry still fire.
Valid queries (incl. empty results): unaffected — hasErrors is false, so the effect behaves exactly as today.
Retry after a transient/server error: the user re‑submitting the same query goes through the router (handleSearchAction), which calls search() directly and is not blocked by this effect.
Platforms: the fix is in shared logic (Search/index.tsx), so it covers iOS App (reported) plus every other platform.
Optional hardening (defense‑in‑depth): the underlying fragility is that a "resolved‑with‑error" query looks identical to a "never‑searched" query because failureData deletes data. If we want the page skeleton to never reappear once a query has resolved to an error, useSearchLoadingState could also treat a present-but-loading/errored snapshot as "not loading". The effect‑guard above is sufficient on its own; this is only listed for completeness.
What alternative solutions did you explore? (Optional)
Stop failureData from deleting data (don't merge data: null). This would make hasNoData stay false after a failure so the page never falls back to the skeleton. Rejected: clearing stale data on failure is intentional (we don't want to show stale rows behind an error), and it would mask, not fix, the redundant re‑search.
Make useSearchLoadingState not return true while a search is actively loading for an already‑mounted query. This narrows the skeleton flash window but still leaves the pointless re‑request firing on every mount; it treats the symptom rather than the cause. Better as the optional hardening above, layered on top of the effect guard.
Reset to the canned search on error (the existing index.tsx#L1432-L1447 behaviour) for the /search route too. Rejected: the expected result is that the error page stays, not that the query is silently replaced.
changed the title [-]Spend-"Something went wrong" screen for a failing query flashes[/-][+][$250] Spend-"Something went wrong" screen for a failing query flashes[/+]on Jun 3, 2026
@nabi-ebrahimi can you please accept the job below? Please reply here and tag me once you have.
If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal. https://www.upwork.com/jobs/~022078242745554726073
Contributor: @nabi-ebrahimi due $125 via Upwork Contributor+: @oqildev due $125 via NewDot
@nabi-ebrahimi can you please accept the job below? Please reply here and tag me once you have. If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal. https://www.upwork.com/jobs/~022078242745554726073
Activity
applause-bot commentedon Jun 3, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/32ec2cac45ba9245f03eacdf9fee4c6f9bdbf239583c023fddd5180354c06784
MelvinBot commentedon Jun 3, 2026
Proposal
What is the root cause of that problem?
The "Something went wrong" page is
FullPageErrorView, andSearchrenders it whenever the current search snapshot has anyerrors— that branch is gated only onhasErrors, with no guard for the "request still in flight" state.The flash happens because
searchResults.errorsis toggled on every search round-trip: eachsearch()call optimistically clears it (errors: null), and the failure response re-sets it. So as the failing query moves through loading → error (and across any re-render/re-request), theerrorskey briefly clears and the error page unmounts for a frame before reappearing — the visible flash.The app already has machinery meant to defer the error UI until the response is confirmed (
hasUnresolvedErrors = hasErrors && searchRequestResponseStatusCode === null, which feedsshouldShowLoadingState). But that guard is never applied to the error render branch, and the narrow/mobile page used on iOS never resetssearchRequestResponseStatusCodetonullat the start of a search — unlike the wide page. So the=== nullwindow that's supposed to keep the skeleton up never opens on iOS, which fits the iOS‑App‑only repro.What changes do you think we should make in order to solve the problem?
SearchPageNarrow'shandleSearchAction, resetsearchRequestResponseStatusCodetonullbefore callingsearch(), matching the wide page.FullPageErrorViewwhile the search is still in its loading/transition state), so the transient clear/loading frames show the skeleton instead of flashing the error page.Together these aim to make the error page appear once, after the response is confirmed, instead of flickering during the transition.
What alternative solutions did you explore? (Optional)
Keeping the previously-shown error visible during an immediate re-search (instead of optimistically clearing
errors) would also remove the flash, but it's more invasive than the gating approach above.Code references & evidence chain
SHA:
b8898bf30ca7cf361f146cc13018b050b124669ahasErrors:src/components/Search/index.tsx:1718-1733hasErrorsdefinition (driven purely bysearchResults.errors):src/components/Search/index.tsx:435src/components/Search/index.tsx:520-522errors: null):src/libs/actions/Search.ts:313-319src/libs/actions/Search.ts:334-347nullbefore searching:src/pages/Search/SearchPage.tsx:111-120src/pages/Search/SearchPageNarrow/index.tsx:167-173Open question to confirm on an iOS build: what triggers the extra search round-trip (or render) that clears
errorsmid-flow on iOS. The totals/group retry path doesn't apply to atype:chatquery (shouldCalculateTotals/validGroupByare both false), so the trigger is likely platform render/Onyx-propagation timing. The existing[Search] Showing skeletonlog (index.tsx:694) can be used to observe the transition order during a repro.I also ruled out the canned-query reset effect (
index.tsx:1432): it only fires on route/(the reports home) or whenshouldResetSearchQueryis set, neither of which applies to a typed query submitted on the/searchpage.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/92462)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
mukhrr commentedon Jun 3, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-06-03 03:01:17 UTC.
Proposal
What is the root cause of that problem?
The initial
search()for a query is issued at the page level byuseSearchPageSetupbeforeSearchmounts, butSearchkept its own mount-time effect that re-issues the same query as soon as it mounts. That call is redundant —Searchonly ever mounts underSearchPage, keyed byqueryJSON.hash, always after the page-level request was already issued.The redundant call produces both symptoms:
failureDatadeletessnapshot.dataand writessnapshot.errors.useSearchLoadingStatedeliberately letsSearchmount when errors are present so it can renderFullPageErrorView. On mount, the redundant effect re-issues the failing query; itsoptimisticDatasetserrors: null, putting the snapshot back to "no data, no errors" → the skeleton replaces the error view → the request fails again → error view → remount → re-issue — an infinite loop of flashing screens and network requests.Searchmounts after the first request resolved, so the in-flight dedupe insearch()can't catch it → one duplicate API request per search.What changes do you think we should make in order to solve the problem?
1. Make
useSearchPageSetupthe single owner of every initial (offset 0) fetch — including the cached-snapshot refresh.Remove the mount-time
handleSearch()fromSearch. On its own, that removal leaves one gap: onmain, the mount-time call also refreshed an already-cached snapshot wheneverSearchremounted (e.g. flipping Expenses ↔ Reports tabs), which is how rows added/removed elsewhere show up. Onyx mirrors edits to existing snapshot rows automatically, but membership changes need a re-search — pure removal would leave revisited tabs stale.So the page hook gets a per-instance
lastFetchedHashReftracking the last hash it fetched. Navigating to a hash it hasn't fetched firessearch()even when a cached snapshot exists (the refreshmaindid on remount); dep-driven re-runs for the same hash (load completion, failure, reconnect) are blocked by the ref:Loop-safety, verified against the Onyx writes:
failureDatakeepssearch.type/search.statusand setserrors, soisSearchDataLoadedtreats a failed snapshot as loaded — with the ref blocking same-hash re-runs, nothing re-issues the failed query and the error page renders once and stays. Revisiting a previously failed tab retries it once (a fresh attempt), never loops.2.
Searchkeeps only the fetches the page hook can't know about, each as its own single-trigger effect — pagination, reconnect refresh, and the totals/grouped retry flag:fetchMoreResultsstays offset-only, so offline load-more behaves likemain: scrolling offline only advances the offset, and the pending page fetches once on reconnect.The two mount-time special cases existed only to serve the redundant call and are deleted with it, with their original jobs verified covered:
useEffectwith no focus gate, so migrated users behind the welcome modal still get their initial fetch.skipWaitForWrites.3. Companion fix:
SearchPageNarrow'shandleSearchActiondoesn't clearsearchRequestResponseStatusCodebefore re-searching, unlikeSearchPage's, so a stale status code can leak into the next request's error state:} else { + setSearchRequestResponseStatusCode(null); search(value)?.then((jsonCode) => setSearchRequestResponseStatusCode(Number(jsonCode ?? 0))); }What alternative solutions did you explore? (Optional)
n/a
yusufdeveloper2903 commentedon Jun 3, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a search query fails (e.g.
type:chat category:abcd, which the backend rejects withINVALID_SEARCH_QUERY), the "Something went wrong" error page does not stay on screen — it flashes/flickers, repeatedly toggling with the loading skeleton instead of rendering stably.What is the root cause of that problem?
The flash is a self‑perpetuating skeleton ↔ error‑page loop that is unique to failing queries. It comes from three pieces of code interacting:
1. A failed search deletes
datafrom the snapshot.The
failureDatafor theSearchrequest mergesdata: nullinto the snapshot:App/src/libs/actions/Search.ts
Lines 334 to 348 in 2d8b35e
In Onyx, merging
nullfor a key deletes it, so after a failuresearchResults.data === undefined(not an empty array). A successful search instead setsdatato a defined value — this asymmetry is the seed of the bug.2. The page‑level skeleton gate treats "no data + no errors" as "still loading".
The narrow page chooses between the page skeleton and mounting
<Search>(which renders theFullPageErrorView) usinguseSearchLoadingState:App/src/hooks/useSearchLoadingState.ts
Lines 24 to 35 in 2d8b35e
It returns
true(→ show page skeleton, unmount<Search>and its error view) whenever there is no data and no errors. This is reinforced one level up inSearchPage, which only forwardssearchResultswhen there is data or errors, and forwardsundefinedotherwise:App/src/pages/Search/SearchPage.tsx
Lines 74 to 79 in 2d8b35e
The skeleton ↔ error swap happens here:
App/src/pages/Search/SearchPageNarrow/index.tsx
Lines 385 to 415 in 2d8b35e
3.
<Search>re‑fires the search every time it mounts — even for an already‑errored query.When
<Search>mounts (which, for a failing query, only happens after the error has arrived), this effect runs and unconditionally callshandleSearchbecausesearchResults.search.isLoadingis alreadyfalse:App/src/components/Search/index.tsx
Lines 704 to 740 in 2d8b35e
That redundant re‑search applies
optimisticData, which clearserrors(errors: null) and setsisLoading: true:App/src/libs/actions/Search.ts
Lines 300 to 320 in 2d8b35e
The error page itself is rendered here:
App/src/components/Search/index.tsx
Lines 1718 to 1734 in 2d8b35e
Putting it together — the loop for a failing query:
search()runs → optimistic (dataundefined,errors: null, loading) → page skeleton.INVALID_SEARCH_QUERY→failureDatamerges (datadeleted →undefined,errorsset, loading false) →useSearchLoadingStatereturnsfalse→<Search>mounts → error page appears. ✅<Search>'s mount effect (index.tsx#L704) fires a redundant re‑search → optimistic clearserrorstonull,datais stillundefined→ state is now "no data and no errors" →SearchPageforwardsundefined/useSearchLoadingStatereturnstrue→ page skeleton,<Search>unmounts → error page disappears (flash).errorsset →<Search>remounts → its mount effect fires another re‑search → back to step 3 → continuous flashing.A successful query never flashes because step 2 sets
datato a defined value, so the re‑search in step 3 keepshasNoData === false;<Search>stays mounted and just refreshes in place. The flash is therefore specific to failed queries, exactly as reported.What changes do you think we should make in order to solve the problem?
Break the loop at its source: do not re‑fire a search for a query whose latest result already errored. There is no value in immediately re‑running a query the server just rejected, and doing so is what clears
errors, collapses the state to "no data + no errors", and unmounts the error view.In
src/components/Search/index.tsx, add ahasErrorsearly‑return to the search‑triggering effect (L704):The same guard should be applied to the totals/grouped retry effect so it can't re‑search an errored result either:
App/src/components/Search/index.tsx
Lines 742 to 763 in 2d8b35e
With this guard, after step 2 above
<Search>mounts, the effect seeshasErrors === trueand returns without re‑searching.errorsis never cleared, the page never swaps back to the skeleton, and the "Something went wrong" screen renders stably — matching the expected result.Why this is the right layer: the flash is caused by a needless re‑request, not by the rendering logic. Editing the query to something valid still works (that's a new hash → new search triggered by the router submit /
queryJSONchange withhasErrors === false), and the legitimate offline→online recovery path (comingBackOnlineWithNoResults) is untouched.Edge cases covered:
hasErrorsis already gated by!isOffline(index.tsx#L435), so offline behaviour is unchanged; the offline error/empty handling and thecomingBackOnlineWithNoResultsretry still fire.hasErrorsisfalse, so the effect behaves exactly as today.handleSearchAction), which callssearch()directly and is not blocked by this effect.Search/index.tsx), so it covers iOS App (reported) plus every other platform.Optional hardening (defense‑in‑depth): the underlying fragility is that a "resolved‑with‑error" query looks identical to a "never‑searched" query because
failureDatadeletesdata. If we want the page skeleton to never reappear once a query has resolved to an error,useSearchLoadingStatecould also treat a present-but-loading/errored snapshot as "not loading". The effect‑guard above is sufficient on its own; this is only listed for completeness.What alternative solutions did you explore? (Optional)
Stop
failureDatafrom deletingdata(don't mergedata: null). This would makehasNoDatastayfalseafter a failure so the page never falls back to the skeleton. Rejected: clearing stale data on failure is intentional (we don't want to show stale rows behind an error), and it would mask, not fix, the redundant re‑search.Make
useSearchLoadingStatenot returntruewhile a search is actively loading for an already‑mounted query. This narrows the skeleton flash window but still leaves the pointless re‑request firing on every mount; it treats the symptom rather than the cause. Better as the optional hardening above, layered on top of the effect guard.Reset to the canned search on error (the existing
index.tsx#L1432-L1447behaviour) for the/searchroute too. Rejected: the expected result is that the error page stays, not that the query is silently replaced.melvin-bot commentedon Jun 3, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @jjcoffee (
External)wildan-m commentedon Jun 3, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
moxw commentedon Jun 3, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
melvin-bot commentedon Jun 3, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022062004611029237958
[-]Spend-"Something went wrong" screen for a failing query flashes[/-][+][$250] Spend-"Something went wrong" screen for a failing query flashes[/+]115 remaining items
melvin-bot commentedon Jul 15, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)mallenexpensify commentedon Jul 17, 2026
Payment Summary
Contributor: @nabi-ebrahimi due $125 via Upwork
Contributor+: @QichenZhu due $125 via NewDot
@nabi-ebrahimi can you please accept the job below? Please reply here and tag me once you have.
If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal.
https://www.upwork.com/jobs/~022078242745554726073
^ Test case created. Thx
oqildev commentedon Jul 18, 2026
@mallenexpensify
Ohh. It’s not me. Wrong assignement.
Thanks😊
nabi-ebrahimi commentedon Jul 20, 2026
@mallenexpensify, Accepted the offer. thanks.
melvin-bot commentedon Jul 20, 2026
@QichenZhu Huh... This is 4 days overdue. Who can take care of this?
mallenexpensify commentedon Jul 20, 2026
@nabi-ebrahimi paid, summary updated above. Thx.
Thanks @oqildev , I was a lil too quick
@QichenZhu paid, summary updated above. Thx.
trjExpensify commentedon Aug 3, 2026
approved $250 for @QichenZhu
QichenZhu commentedon Aug 4, 2026
trjExpensify commentedon Aug 4, 2026
Ah yeah cool, you submitted $125 so all good.