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
Search - Creating a new saved search also updates the previously saved search #106595
Version Number: v9.5.36-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:#106391 Email or phone of affected tester (no customers): n/a Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: Mac 26.5.1 Safari/Chrome App Component: Search
Reopening QA Original displayed Beta after creating QA Copy, but Reset restored Alpha, indicating remembered unsaved filters rather than an overwritten saved definition. QA has also closed the issue after rechecking.
Step
Status
1. Navigate to SpendSpend and Expenses headings were visible.
✅
2. Set Merchant to AlphaFilters displayed Merchant: Contains “Alpha”.
✅
3. Save as QA Original and reopenQA Original reopened with Alpha retained.
✅
4. Change Merchant to BetaQA Original displayed Merchant: Contains “Beta”.
✅
5. Select SaveThe dialog offered updating QA Original or creating a new search.
✅
6. Choose Create newThe naming page opened.
✅
7. Save as QA CopyQA Copy displayed Beta; both saved searches were available.
✅
8. Reopen QA Original and verify Alpha remainsQA Original displayed Beta, failing the reported expectation. Root cause of the displayed behavior: executing the edited query remembers Beta under the original search’s key in SEARCH_FILTERS (Search.ts:1479–1492). Reopening a saved search prefers that remembered query (SearchNavigationUtils.ts:39–49). Alternative checked: Create new does not update the original ID. Its branch opens the naming page, which saves using a fresh ID (SearchFiltersSaveButton.tsx:46–66, SearchSavePage.tsx:201–211). Server persistence was not independently inspected.
❌
9. Reset QA Original to distinguish remembered edits from its saved definitionReset restored Alpha and removed the Reset/Save controls. Recommendation: No code fix is justified for the withdrawn overwrite report. Remembering unsaved refinements is explicitly covered by an existing navigation test. If creating a copy should also reset the original’s remembered filters, confirm that product requirement separately and add regression coverage distinguishing saved definitions from remembered state. Related context:Add a Save button when a search differs from its default view defines the create/update flow; it is not a confirmed duplicate.
Please re-state the problem that we are trying to solve in this issue.
When editing filters on an existing saved search and selecting "Save" -> "Create new" to save the modified filters as a separate new saved search, the previously saved search also retains the modified filters instead of preserving its original saved criteria.
What is the root cause of that problem?
When modifying filters on an active saved search (e.g. changing merchant from Alpha to Beta while viewing QA Original), src/libs/actions/Search.ts optimistically updates the uncommitted draft query into ONYXKEYS.SEARCH_FILTERS[savedSearch_<originalID>].
When the user clicks "Save" and selects "Create new" in SearchFiltersSaveButton.tsx, the user navigates to SearchSavePage.tsx, generating a new saved search ID (rand64()) with the new query and switching the active search key to savedSearch_<newID>.
However, ONYXKEYS.SEARCH_FILTERS[savedSearch_<originalID>] is never cleared or reset back to the original saved search query (item.query).
Consequently, when the user navigates back to the previous saved search, SavedSearchList.tsx:146 resolves the query via:
Because getLastSearchQuery(searchFilters, ...) returns the uncommitted draft query (Beta), SavedSearchList loads the modified query rather than the saved query (Alpha), causing the original saved search to appear modified.
What changes do you think we should make in order to solve the problem?
In src/pages/Search/SearchSavePage.tsx (inside onSaveSearch):
When a new saved search is created branching off an existing active saved search (activeSavedSearchID), reset or remove the draft uncommitted query from ONYXKEYS.SEARCH_FILTERS for that savedSearchIDToSearchKey(activeSavedSearchID) (e.g., reverting searchFilters[savedSearchKey] back to activeSavedSearch.query or setting it to null).
Alternatively, in SearchFiltersSaveButton.tsx:
When decision.action === ModalActions.CONFIRM ("Create new") is selected, clear or reset the temporary search filters draft for activeSavedSearchID before calling openSaveSearchPage().
What alternative solutions did you explore? (Optional)
Bypassing getLastSearchQuery in SavedSearchList.tsx: Rejected because draft filter caching is intentional for active exploration, but draft filters should not bleed across when explicitly choosing to fork into a new saved search.
What automated tests can you add to prevent this from re-occurring?
In tests/unit/SearchSavePageTest.tsx or SearchFiltersSaveButtonTest.tsx:
Add a test verifying that when modifying filters on an active saved search and choosing "Create new", the original saved search's draft in ONYXKEYS.SEARCH_FILTERS is reset so that reopening the original saved search retains its original query criteria.
Please re-state the problem that we are trying to solve in this issue.
When a user opens an existing saved search (e.g. QA Original with merchant:Alpha), modifies a filter (e.g. changing merchant to Beta), clicks Save -> Create new, and saves the new search as QA Copy, reopening QA Original from the Saved Searches menu displays the modified Beta filter instead of its original Alpha filter.
What is the root cause of that problem?
While viewing QA Original (searchKey = savedSearch_<originalID>), editing a filter dispatches search() (src/libs/actions/Search.ts:1504-1514), which optimistically caches the modified inputQuery (merchant:Beta) under ONYXKEYS.SEARCH_FILTERS[savedSearch_<originalID>].query.
When the user clicks Save and selects Create new in src/components/Search/SearchPageHeader/SearchFiltersSaveButton.tsx:57-60, SearchSavePage.tsx (onSaveSearch, lines 201-212) creates a new saved search ID (const id = rand64()), calls saveSearch({id, queryJSON: currentSearchQueryJSON, newName}), and updates the route parameter searchKey to savedSearchIDToSearchKey(id).
However, neither SearchSavePage.tsx nor saveSearch() clears or resets the uncommitted draft query stored at ONYXKEYS.SEARCH_FILTERS[currentSearchKey] (the source saved search from which the user branched Create new).
Worse still, there is a second side effect in src/components/Search/hooks/useSearchKeyParam.ts:70-82:
Because searchFilters[savedSearch_<originalID>].query still has the exact same Beta query hash as the newly created QA Copy, Array.prototype.find matches <originalID> first whenever searchKey is resolved from the query! And when the user clicks QA Original in src/pages/Search/SavedSearchList.tsx:146 (or navigateToFlatNavItem in src/libs/SearchNavigationUtils.ts:49), getLastSearchQuery(searchFilters, savedSearchIDToSearchKey(key)) returns the stale Beta draft instead of item.query (Alpha).
What changes do you think we should make in order to solve the problem?
Clear the remembered draft entry in ONYXKEYS.SEARCH_FILTERS whenever a saved search is saved (both for the target savedSearchIDToSearchKey(id) and, when branching via Create new from an existing saved search, for the source sourceSearchKey):
In src/libs/actions/Search.ts (saveSearch, lines 935-977), accept an optional sourceSearchKey?: SearchKey parameter and clear the corresponding ONYXKEYS.SEARCH_FILTERS entry (or entries) in optimisticData:
In src/pages/Search/SearchSavePage.tsx (lines 198-212), destructure currentSearchKey from useSearchQueryContext() and pass sourceSearchKey: currentSearchKey into saveSearch:
If the user opens the Create new page (SearchSavePage) and presses Back/Cancel without submitting the form, ONYXKEYS.SEARCH_FILTERS[currentSearchKey] remains intact so their in-progress filter edits on the original search are not lost.
Once the user submits Save view on SearchSavePage, the uncommitted draft on sourceSearchKey (savedSearch_<originalID>) is cleared in ONYXKEYS.SEARCH_FILTERS, so reopening QA Original loads its saved Alpha query cleanly.
What alternative solutions did you explore? (Optional)
Clearing ONYXKEYS.SEARCH_FILTERS inside SearchFiltersSaveButton.tsx as soon as the user clicks Create new in the decision modal: rejected because if the user subsequently cancels/closes SearchSavePage without saving the new view, they would lose their unsaved filter edits on the current screen. Clearing sourceSearchKey inside saveSearch upon actual submission of SearchSavePage avoids data loss on cancel.
Activity
applause-bot commentedon Nov 11, 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/ad1e48ead364686b7208302f819a8229ffd07ee1e71e331b6573950c6266f463
MelvinBot commentedon Nov 11, 2026
🤖 Web test steps verification results: ❌ fail
Reopening QA Original displayed Beta after creating QA Copy, but Reset restored Alpha, indicating remembered unsaved filters rather than an overwritten saved definition. QA has also closed the issue after rechecking.
1. Navigate to Spend
Spend and Expenses headings were visible.2. Set Merchant to Alpha
Filters displayed Merchant: Contains “Alpha”.3. Save as QA Original and reopen
QA Original reopened with Alpha retained.4. Change Merchant to Beta
QA Original displayed Merchant: Contains “Beta”.5. Select Save
The dialog offered updating QA Original or creating a new search.6. Choose Create new
The naming page opened.7. Save as QA Copy
QA Copy displayed Beta; both saved searches were available.8. Reopen QA Original and verify Alpha remains
QA Original displayed Beta, failing the reported expectation.Root cause of the displayed behavior: executing the edited query remembers Beta under the original search’s key in SEARCH_FILTERS (Search.ts:1479–1492). Reopening a saved search prefers that remembered query (SearchNavigationUtils.ts:39–49).
Alternative checked: Create new does not update the original ID. Its branch opens the naming page, which saves using a fresh ID (SearchFiltersSaveButton.tsx:46–66, SearchSavePage.tsx:201–211). Server persistence was not independently inspected.
9. Reset QA Original to distinguish remembered edits from its saved definition
Reset restored Alpha and removed the Reset/Save controls.Recommendation: No code fix is justified for the withdrawn overwrite report. Remembering unsaved refinements is explicitly covered by an existing navigation test. If creating a copy should also reset the original’s remembered filters, confirm that product requirement separately and add regression coverage distinguishing saved definitions from remembered state.
Related context: Add a Save button when a search differs from its default view defines the create/update flow; it is not a confirmed duplicate.
view run · no recording available
mitarachim commentedon Nov 11, 2026
Sorry for the confusion. We have decided to reopen the issue after double-checking all the steps once again.
tranvanminhnhat commentedon Nov 11, 2026
Contributor details
Your Expensify account email: tranvanminhnhat99@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01867c2936746cf5ca
Proposal
Please re-state the problem that we are trying to solve in this issue.
When editing filters on an existing saved search and selecting "Save" -> "Create new" to save the modified filters as a separate new saved search, the previously saved search also retains the modified filters instead of preserving its original saved criteria.
What is the root cause of that problem?
QA Original),src/libs/actions/Search.tsoptimistically updates the uncommitted draft query intoONYXKEYS.SEARCH_FILTERS[savedSearch_<originalID>].SearchFiltersSaveButton.tsx, the user navigates toSearchSavePage.tsx, generating a new saved search ID (rand64()) with the new query and switching the active search key tosavedSearch_<newID>.ONYXKEYS.SEARCH_FILTERS[savedSearch_<originalID>]is never cleared or reset back to the original saved search query (item.query).SavedSearchList.tsx:146resolves the query via:getLastSearchQuery(searchFilters, ...)returns the uncommitted draft query (Beta),SavedSearchListloads the modified query rather than the saved query (Alpha), causing the original saved search to appear modified.What changes do you think we should make in order to solve the problem?
src/pages/Search/SearchSavePage.tsx(insideonSaveSearch):activeSavedSearchID), reset or remove the draft uncommitted query fromONYXKEYS.SEARCH_FILTERSfor thatsavedSearchIDToSearchKey(activeSavedSearchID)(e.g., revertingsearchFilters[savedSearchKey]back toactiveSavedSearch.queryor setting it tonull).SearchFiltersSaveButton.tsx:decision.action === ModalActions.CONFIRM("Create new") is selected, clear or reset the temporary search filters draft foractiveSavedSearchIDbefore callingopenSaveSearchPage().What alternative solutions did you explore? (Optional)
getLastSearchQueryinSavedSearchList.tsx: Rejected because draft filter caching is intentional for active exploration, but draft filters should not bleed across when explicitly choosing to fork into a new saved search.What automated tests can you add to prevent this from re-occurring?
In
tests/unit/SearchSavePageTest.tsxorSearchFiltersSaveButtonTest.tsx:ONYXKEYS.SEARCH_FILTERSis reset so that reopening the original saved search retains its original query criteria.melvin-bot commentedon Nov 11, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
ZhenjaHorbach commentedon Nov 11, 2026
Okay
Looks like this issue is in prod also
But I will check!
Screen.Recording.2026-11-11.at.08.39.32.mov
cocvn157 commentedon Nov 15, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user opens an existing saved search (e.g.
QA Originalwithmerchant:Alpha), modifies a filter (e.g. changingmerchanttoBeta), clicks Save -> Create new, and saves the new search asQA Copy, reopeningQA Originalfrom the Saved Searches menu displays the modifiedBetafilter instead of its originalAlphafilter.What is the root cause of that problem?
QA Original(searchKey = savedSearch_<originalID>), editing a filter dispatchessearch()(src/libs/actions/Search.ts:1504-1514), which optimistically caches the modifiedinputQuery(merchant:Beta) underONYXKEYS.SEARCH_FILTERS[savedSearch_<originalID>].query.src/components/Search/SearchPageHeader/SearchFiltersSaveButton.tsx:57-60,SearchSavePage.tsx(onSaveSearch, lines 201-212) creates a new saved search ID (const id = rand64()), callssaveSearch({id, queryJSON: currentSearchQueryJSON, newName}), and updates the route parametersearchKeytosavedSearchIDToSearchKey(id).SearchSavePage.tsxnorsaveSearch()clears or resets the uncommitted draft query stored atONYXKEYS.SEARCH_FILTERS[currentSearchKey](the source saved search from which the user branched Create new).src/components/Search/hooks/useSearchKeyParam.ts:70-82:searchFilters[savedSearch_<originalID>].querystill has the exact sameBetaquery hash as the newly createdQA Copy,Array.prototype.findmatches<originalID>first wheneversearchKeyis resolved from the query! And when the user clicksQA Originalinsrc/pages/Search/SavedSearchList.tsx:146(ornavigateToFlatNavIteminsrc/libs/SearchNavigationUtils.ts:49),getLastSearchQuery(searchFilters, savedSearchIDToSearchKey(key))returns the staleBetadraft instead ofitem.query(Alpha).What changes do you think we should make in order to solve the problem?
Clear the remembered draft entry in
ONYXKEYS.SEARCH_FILTERSwhenever a saved search is saved (both for the targetsavedSearchIDToSearchKey(id)and, when branching via Create new from an existing saved search, for the sourcesourceSearchKey):In
src/libs/actions/Search.ts(saveSearch, lines 935-977), accept an optionalsourceSearchKey?: SearchKeyparameter and clear the correspondingONYXKEYS.SEARCH_FILTERSentry (or entries) inoptimisticData:In
src/pages/Search/SearchSavePage.tsx(lines 198-212), destructurecurrentSearchKeyfromuseSearchQueryContext()and passsourceSearchKey: currentSearchKeyintosaveSearch:SearchSavePage) and presses Back/Cancel without submitting the form,ONYXKEYS.SEARCH_FILTERS[currentSearchKey]remains intact so their in-progress filter edits on the original search are not lost.SearchSavePage, the uncommitted draft onsourceSearchKey(savedSearch_<originalID>) is cleared inONYXKEYS.SEARCH_FILTERS, so reopeningQA Originalloads its savedAlphaquery cleanly.What alternative solutions did you explore? (Optional)
ONYXKEYS.SEARCH_FILTERSinsideSearchFiltersSaveButton.tsxas soon as the user clicks Create new in the decision modal: rejected because if the user subsequently cancels/closesSearchSavePagewithout saving the new view, they would lose their unsaved filter edits on the current screen. ClearingsourceSearchKeyinsidesaveSearchupon actual submission ofSearchSavePageavoids data loss on cancel.ZhenjaHorbach commentedon Nov 16, 2026
Not overdue
Will check today
ZhenjaHorbach commentedon Nov 16, 2026
@cocvn157
Stop posting proposals without Help Wanted label
Otherwise, you will be banned soon