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-05-12] [$250] Reports - Categories are not saving in the saved search after you rename it #88152
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorNeeds ReproductionReproducible steps needed
Version Number: Reproducible in staging?: Needs Reproduction Reproducible in production?: Needs Reproduction If this was caught during regression testing, add the test name, ID and link from BrowserStack: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by:@marianaabussamra Slack conversation (hyperlinked to channel name): #expensify_bugs
Action Performed:
Reports page
Expand Filters
Select multiple categories
Save search
Click on the three dots next to that search
Rename
Reopen the search and check the categories
Only a few categories are checked (most of them have been automatically unchecked)
Expected Result:
The categories should remain checked if they rename the saved search
Actual Result:
If they check the categories in that saved search before renaming it, they are still all checked. The issue happens after they renamed it, where most of the categories are unchecked automatically
Workaround:
Unknown
Platforms:
Select the officially supported platforms where the issue was reproduced:
The SEARCH_SAVED_SEARCH_RENAME route does not URL-encode the q (query) parameter when constructing the navigation URL. At ROUTES.ts:313, the query string is interpolated directly:
Compare with SEARCH_ROOT at ROUTES.ts:306, which correctly encodes the same type of parameter:
`search?q=${encodeURIComponent(query)}...`
When React Navigation parses the unencoded URL, the query-string library splits on & characters and strips # fragments. If any category name contains & (e.g., "Food & Beverages"), everything after that & is treated as a separate URL parameter — truncating the query and losing all subsequent filter values. Characters like #, %, and + in category names cause similar corruption. The truncated query is then saved to the backend via saveSearch(), making the data loss permanent.
What changes do you think we should make in order to solve the problem?
Add encodeURIComponent to the q parameter in the SEARCH_SAVED_SEARCH_RENAME route, matching the pattern already used by SEARCH_ROOT:
In ROUTES.ts:313, change the getRoute to encode the jsonQuery parameter:
React Navigation already calls decodeURIComponent when parsing route params, so SavedSearchRenamePage will receive the correct decoded value without any changes needed on the receiving end.
What alternative solutions did you explore? (Optional)
An alternative would be to pass the query via navigation state params instead of URL query params, but that would be inconsistent with how SEARCH_ROOT handles it and would require more invasive changes to the navigation setup.
Investigation details
Data flow of the bug:
User's saved search has a query like type:expense category:Food & Beverages,Travel,Office
User clicks rename → SearchUIUtils.ts:4132 navigates with inputQuery passed unencoded
buildSearchQueryJSON() parses the truncated query → most categories are lost
saveSearch() persists the corrupted query to the backend, making the loss permanent
Note: The name param is correctly pre-encoded via encodeURIComponent(itemName) at the call site, but jsonQuery receives no encoding at all — confirming this is an oversight rather than an intentional design choice.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
changed the title [-]Reports - Categories are not saving in the saved search after you rename it[/-][+][$250] Reports - Categories are not saving in the saved search after you rename it[/+]on Apr 16, 2026
Please re-state the problem that we are trying to solve in this issue.
When a user creates a saved search filtering by multiple categories and then renames the saved search, reopening the search shows that most of the previously selected categories have become unchecked. The categories that survive the rename appear to be the first few; everything after a certain point is silently dropped.
What is the root cause of that problem?
The rename route at SEARCH_SAVED_SEARCH_RENAME builds the URL by interpolating the saved query string directly into the q= query parameter without URL-encoding it:
A typical saved search query containing multiple categories looks like type:expense category:Travel,"Office Supplies","Travel & Entertainment","Software". Once that string is interpolated unencoded into the URL, the unencoded & is parsed as a query-parameter delimiter. React Navigation reads route.params.q as only the substring up to the first & — so the value handed to SavedSearchRenamePage becomes type:expense category:Travel,"Office Supplies","Travel (truncated). Spaces, quotes, #, and + in category values have similar URL-decoding hazards.
SavedSearchRenamePage then rebuilds the JSON from this truncated string and saves it back to Onyx:
saveSearch writes that truncated query string back into the saved search entry, so the user-visible categories after reopening reflect only the survivors that appeared before the first URL-special character:
This is why "most" categories become unchecked rather than "all" — categories whose serialized form sits before the truncation point survive, the rest are silently dropped. Standard accounting category names like "Travel & Entertainment" and "Meals & Entertainment" reliably trigger this on the very first rename.
The same file already encodes other query strings correctly. The SEARCH_ROOT route encodes its q and rawQuery parameters via encodeURIComponent:
The rename route is the one outlier that forgot to encode.
What changes do you think we should make in order to solve the problem?
Wrap the jsonQuery interpolation in encodeURIComponent inside SEARCH_SAVED_SEARCH_RENAME.getRoute, mirroring how SEARCH_ROOT.getRoute already handles its query parameter on the line above. After the change, the rename URL becomes percent-encoded, React Navigation decodes route.params.q back to the original full query string, and SavedSearchRenamePage rebuilds the JSON from the complete filter set — so the rename writes the unchanged query back into Onyx and the categories remain checked when the search is reopened.
No other change is required: the rest of the rename flow already does the right thing once it receives an intact q. SavedSearchRenamePage's existing applyFiltersAndNavigate call to ROUTES.SEARCH_ROOT.getRoute({query: q, name: newName?.trim()}) still works correctly because SEARCH_ROOT.getRoute independently encodes its own query parameter.
What alternative solutions did you explore? (Optional)
Encoding at the call site in SearchUIUtils.ts:getOverflowMenu (wrapping inputQuery with encodeURIComponent before passing it to getRoute) was considered, but encoding inside the route definition matches the pattern already used by sibling routes in the same file (SEARCH_ROOT, SEARCH_HOLD, etc.) and keeps the encoding contract owned by the route, so future callers cannot reintroduce the same bug by forgetting to encode upstream.
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorNeeds ReproductionReproducible steps needed
Activity
MelvinBot commentedon Apr 16, 2026
This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989
MelvinBot commentedon Apr 16, 2026
Proposal
What is the root cause of that problem?
The
SEARCH_SAVED_SEARCH_RENAMEroute does not URL-encode theq(query) parameter when constructing the navigation URL. AtROUTES.ts:313, the query string is interpolated directly:Compare with
SEARCH_ROOTatROUTES.ts:306, which correctly encodes the same type of parameter:When React Navigation parses the unencoded URL, the
query-stringlibrary splits on&characters and strips#fragments. If any category name contains&(e.g., "Food & Beverages"), everything after that&is treated as a separate URL parameter — truncating the query and losing all subsequent filter values. Characters like#,%, and+in category names cause similar corruption. The truncated query is then saved to the backend viasaveSearch(), making the data loss permanent.What changes do you think we should make in order to solve the problem?
Add
encodeURIComponentto theqparameter in theSEARCH_SAVED_SEARCH_RENAMEroute, matching the pattern already used bySEARCH_ROOT:In
ROUTES.ts:313, change thegetRouteto encode thejsonQueryparameter:React Navigation already calls
decodeURIComponentwhen parsing route params, soSavedSearchRenamePagewill receive the correct decoded value without any changes needed on the receiving end.What alternative solutions did you explore? (Optional)
An alternative would be to pass the query via navigation state params instead of URL query params, but that would be inconsistent with how
SEARCH_ROOThandles it and would require more invasive changes to the navigation setup.Investigation details
Data flow of the bug:
type:expense category:Food & Beverages,Travel,OfficeSearchUIUtils.ts:4132navigates withinputQuerypassed unencodedsearch/saved-search/rename?name=...&q=type:expense category:Food & Beverages,Travel,Officequery-stringparser splits on&→qbecomestype:expense category:Food(truncated)SavedSearchRenamePage.tsxreceives the truncatedqparambuildSearchQueryJSON()parses the truncated query → most categories are lostsaveSearch()persists the corrupted query to the backend, making the loss permanentNote: The
nameparam is correctly pre-encoded viaencodeURIComponent(itemName)at the call site, butjsonQueryreceives no encoding at all — confirming this is an oversight rather than an intentional design choice.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.melvin-bot commentedon Apr 16, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @hungvu193 (
External)melvin-bot commentedon Apr 16, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022044885836320080410
[-]Reports - Categories are not saving in the saved search after you rename it[/-][+][$250] Reports - Categories are not saving in the saved search after you rename it[/+]wildan-m commentedon Apr 16, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user creates a saved search filtering by multiple categories and then renames the saved search, reopening the search shows that most of the previously selected categories have become unchecked. The categories that survive the rename appear to be the first few; everything after a certain point is silently dropped.
What is the root cause of that problem?
The rename route at
SEARCH_SAVED_SEARCH_RENAMEbuilds the URL by interpolating the saved query string directly into theq=query parameter without URL-encoding it:App/src/ROUTES.ts
Lines 311 to 314 in 858961f
The caller passes the stored
inputQueryraw:App/src/libs/SearchUIUtils.ts
Lines 4115 to 4138 in 858961f
A typical saved search query containing multiple categories looks like
type:expense category:Travel,"Office Supplies","Travel & Entertainment","Software". Once that string is interpolated unencoded into the URL, the unencoded&is parsed as a query-parameter delimiter. React Navigation readsroute.params.qas only the substring up to the first&— so the value handed toSavedSearchRenamePagebecomestype:expense category:Travel,"Office Supplies","Travel(truncated). Spaces, quotes,#, and+in category values have similar URL-decoding hazards.SavedSearchRenamePagethen rebuilds the JSON from this truncated string and saves it back to Onyx:App/src/pages/Search/SavedSearchRenamePage.tsx
Lines 38 to 47 in 858961f
saveSearchwrites that truncated query string back into the saved search entry, so the user-visible categories after reopening reflect only the survivors that appeared before the first URL-special character:App/src/libs/actions/Search.ts
Lines 362 to 402 in 858961f
This is why "most" categories become unchecked rather than "all" — categories whose serialized form sits before the truncation point survive, the rest are silently dropped. Standard accounting category names like "Travel & Entertainment" and "Meals & Entertainment" reliably trigger this on the very first rename.
The same file already encodes other query strings correctly. The
SEARCH_ROOTroute encodes itsqandrawQueryparameters viaencodeURIComponent:App/src/ROUTES.ts
Lines 302 to 308 in 858961f
The rename route is the one outlier that forgot to encode.
What changes do you think we should make in order to solve the problem?
Wrap the
jsonQueryinterpolation inencodeURIComponentinsideSEARCH_SAVED_SEARCH_RENAME.getRoute, mirroring howSEARCH_ROOT.getRoutealready handles itsqueryparameter on the line above. After the change, the rename URL becomes percent-encoded, React Navigation decodesroute.params.qback to the original full query string, andSavedSearchRenamePagerebuilds the JSON from the complete filter set — so the rename writes the unchanged query back into Onyx and the categories remain checked when the search is reopened.No other change is required: the rest of the rename flow already does the right thing once it receives an intact
q.SavedSearchRenamePage's existingapplyFiltersAndNavigatecall toROUTES.SEARCH_ROOT.getRoute({query: q, name: newName?.trim()})still works correctly becauseSEARCH_ROOT.getRouteindependently encodes its ownqueryparameter.Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/88152-encode-saved-search-rename-query?expand=1
What alternative solutions did you explore? (Optional)
Encoding at the call site in
SearchUIUtils.ts:getOverflowMenu(wrappinginputQuerywithencodeURIComponentbefore passing it togetRoute) was considered, but encoding inside the route definition matches the pattern already used by sibling routes in the same file (SEARCH_ROOT,SEARCH_HOLD, etc.) and keeps the encoding contract owned by the route, so future callers cannot reintroduce the same bug by forgetting to encode upstream.aimane-chnaif commentedon Apr 16, 2026
This is no longer reproducible on main/staging
hungvu193 commentedon Apr 19, 2026
Not able to reproduce on latest staging. @izarutskaya Can QA team reproduce this one?
37 remaining items
melvin-bot commentedon May 11, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon May 12, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon May 14, 2026
Payment Summary
Contributor+: @hungvu193 due $250 via NewDot
^ Test case created
JmillsExpensify commentedon May 14, 2026
$250 approved for @hungvu193