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-02-23] Expense - Limit value merges with keyword when saved with space #81166
Version Number: V9 3.11-17 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:#80262 Email or phone of affected tester (no customers):dreamnitethedragon@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Redminote 10S Android 13 App Component: User Settings
Action Performed:
Launch app
Go to reports - filter - Expense
Enter keyword "hi" & save
Enter limi as "10 90" & save
Tap save search
Tap filter
Note keyword field shown as "hi 90"
Expected Result:
Reopening the filter after saving the search should show the keyword field as "hi" and the limit field as "10 90" as user entered.
Actual Result:
After entering keyword "hi" and limit "10 90" in filter and saving the search, reopening the filter shows the keyword field as "hi 90" instead of "hi".
Please re-state the problem that we are trying to solve in this issue.
After entering keyword "hi" and limit "10 90" in filter and saving the search, reopening the filter shows the keyword field as "hi 90" instead of "hi".
What is the root cause of that problem?
After entering keyword "hi" and limit "10 90" in filter and saving the search, reopening the filter shows the keyword field as "hi 90" instead of "hi".
The root cause is in how the search query is parsed. When user enters limit:10 90 in the limit field:
The search parser only accepts numeric values for limit (defined in searchParser.peggy)
The parser correctly parses limit:10 but treats 90 as a freetext filter
Freetext filters are automatically converted to keyword filters (see line 161-176 in searchParser.peggy)
When reopening the filter, buildFilterFormValuesFromQuery combines all keyword values using space delimiter, resulting in hi 90
The issue is in the buildSearchQueryString function where keywords are built using space as delimiter, and the invalid limit value 90 gets added as a keyword.
What changes do you think we should make in order to solve the problem?
We should validate the limit input field to only accept valid numeric values before saving. The validation should be added in the SearchFiltersLimitPage to prevent invalid limit values from being saved:
What alternative solutions did you explore? (Optional)
An alternative approach would be to sanitize the limit value when building the query string in buildQueryStringFromFilterFormValues, extracting only the first valid number. However, this would mask the user's input error rather than providing clear feedback about what went wrong.
Please re-state the problem that we are trying to solve in this issue.
When a user saves an Expense search with keyword "hi" and limit "10 90", reopening the filter shows keyword as "hi 90" and the limit value is wrong. Keyword and limit values that contain spaces get merged so the filter form no longer matches what was saved.
What is the root cause of that problem?
The query string is built by joining filter parts with spaces. The limit value is written without quoting:
SearchQueryUtils.ts L747–L750: limitValue is appended as limit:${limitValue}. If the user enters "10 90", the string becomes limit:10 90.
The search parser treats space as a separator. So ... keyword:hi limit:10 90 is parsed as: keyword "hi", limit "10", and "90" as a separate free-text token. Free text is merged into the keyword filter (see searchParser.peggy L186–L195). So after parse, keyword becomes "hi 90" and limit "10". Root cause: limit is not quoted when it contains spaces, so the part after the space is mis-parsed as keyword.
What changes do you think we should make in order to solve the problem?
Quote the limit value when it contains spaces (or nbsp), using the existing sanitizeSearchValue helper, so the parser receives e.g. limit:"10 90" and keeps it as one value.
src/libs/SearchQueryUtils.ts When pushing the limit into filtersString, pass the value through sanitizeSearchValue so values with spaces are wrapped in double quotes (same behavior as other filters that use sanitizeSearchValue L124–L129).
This way limit:10 90 becomes limit:"10 90", the parser keeps "10 90" as the limit, and the keyword stays "hi".
What alternative solutions did you explore? (Optional)
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
Please re-state the problem that we are trying to solve in this issue.
When a user enters a keyword (e.g., "hi") and a limit with a space (e.g., "10 90") in the expense filter, saves the search, and then reopens the filter, the keyword field incorrectly shows "hi 90" instead of "hi". The "90" from the limit input has merged into the keyword field.
What is the root cause of that problem?
The root cause is in the buildQueryStringFromFilterFormValues function in src/libs/SearchQueryUtils.ts. When converting form values to a query string, the limit value is added without any validation or sanitization:
When a user enters 10 90 as the limit value, this produces limit:10 90 in the query string. When the search parser (searchParser.peggy) parses this query:
limit:10 is parsed as a default filter with value 10
90 becomes a free text filter, which is treated as a keyword
if (word.startsWith('"') &&word.endsWith('"') &&word.length>=2) {
returnword.slice(1, -1);
}
return word;
});
if (value.length>1) {
returnvalue.filter((word) =>word.length>0);
}
return value[0];
}
So when the saved search is loaded back and buildFilterFormValuesFromQuery reconstructs the form values, the 90 is combined with the existing keyword hi, resulting in "hi 90".
What changes do you think we should make in order to solve the problem?
Sanitize the limit value in buildQueryStringFromFilterFormValues before adding it to the query string. Since limit must be a positive integer (as validated in buildSearchQueryJSON at lines 445-448), we should extract only the first valid positive integer from the input:
In src/libs/SearchQueryUtils.ts, modify the limit handling around line 749:
constlimitValue=limit??options?.limit;if(limitValue!==undefined){// Extract only the first valid positive integer from the limit valueconstsanitizedLimit=typeoflimitValue==='string' ? limitValue.trim().split(/\s+/)[0] : limitValue;constnumericLimit=Number(sanitizedLimit);if(Number.isInteger(numericLimit)&&numericLimit>0){filtersString.push(`${CONST.SEARCH.SYNTAX_ROOT_KEYS.LIMIT}:${numericLimit}`);}}
This ensures:
Only the first token (before any space) is used
The value is validated to be a positive integer before being added
Invalid limit values are silently ignored rather than corrupting other filter fields
What alternative solutions did you explore? (Optional)
changed the title [-]Expense - Limit value merges with keyword when saved with space[/-][+][Due for payment 2026-02-23] Expense - Limit value merges with keyword when saved with space[/+]on Feb 16, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.19-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
Issue is ready for payment but no BZ is assigned. @sonialiap you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!
Activity
daledah commentedon Feb 2, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
After entering keyword "hi" and limit "10 90" in filter and saving the search, reopening the filter shows the keyword field as "hi 90" instead of "hi".
What is the root cause of that problem?
After entering keyword "hi" and limit "10 90" in filter and saving the search, reopening the filter shows the keyword field as "hi 90" instead of "hi".
The root cause is in how the search query is parsed. When user enters
limit:10 90in the limit field:limit(defined in searchParser.peggy)App/src/libs/SearchParser/searchParser.peggy
Line 71 in bfc6781
limit:10but treats90as a freetext filterbuildFilterFormValuesFromQuerycombines all keyword values using space delimiter, resulting inhi 90The issue is in the buildSearchQueryString function where keywords are built using space as delimiter, and the invalid limit value
90gets added as a keyword.App/src/libs/SearchQueryUtils.ts
Lines 478 to 520 in bfc6781
What changes do you think we should make in order to solve the problem?
We should validate the limit input field to only accept valid numeric values before saving. The validation should be added in the
SearchFiltersLimitPageto prevent invalid limit values from being saved:What alternative solutions did you explore? (Optional)
An alternative approach would be to sanitize the limit value when building the query string in
buildQueryStringFromFilterFormValues, extracting only the first valid number. However, this would mask the user's input error rather than providing clear feedback about what went wrong.TaduJR commentedon Feb 2, 2026
Assignment here @trjExpensify
samranahm commentedon Feb 2, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user saves an Expense search with keyword "hi" and limit "10 90", reopening the filter shows keyword as "hi 90" and the limit value is wrong. Keyword and limit values that contain spaces get merged so the filter form no longer matches what was saved.
What is the root cause of that problem?
The query string is built by joining filter parts with spaces. The limit value is written without quoting:
limitValueis appended aslimit:${limitValue}. If the user enters "10 90", the string becomeslimit:10 90.The search parser treats space as a separator. So
... keyword:hi limit:10 90is parsed as: keyword "hi", limit "10", and "90" as a separate free-text token. Free text is merged into the keyword filter (see searchParser.peggy L186–L195). So after parse, keyword becomes "hi 90" and limit "10". Root cause: limit is not quoted when it contains spaces, so the part after the space is mis-parsed as keyword.What changes do you think we should make in order to solve the problem?
Quote the limit value when it contains spaces (or nbsp), using the existing
sanitizeSearchValuehelper, so the parser receives e.g.limit:"10 90"and keeps it as one value.src/libs/SearchQueryUtils.ts When pushing the limit into
filtersString, pass the value throughsanitizeSearchValueso values with spaces are wrapped in double quotes (same behavior as other filters that use sanitizeSearchValue L124–L129).const limitValue = limit ?? options?.limit; if (limitValue !== undefined) { - filtersString.push(`${CONST.SEARCH.SYNTAX_ROOT_KEYS.LIMIT}:${limitValue}`); + const limitStr = typeof limitValue === 'number' ? String(limitValue) : limitValue; + filtersString.push(`${CONST.SEARCH.SYNTAX_ROOT_KEYS.LIMIT}:${sanitizeSearchValue(limitStr)}`); }This way
limit:10 90becomeslimit:"10 90", the parser keeps "10 90" as the limit, and the keyword stays "hi".What alternative solutions did you explore? (Optional)
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
trjExpensify commentedon Feb 2, 2026
Assigning the team from: #80262
cosmicvulpes commentedon Feb 2, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user enters a keyword (e.g., "hi") and a limit with a space (e.g., "10 90") in the expense filter, saves the search, and then reopens the filter, the keyword field incorrectly shows "hi 90" instead of "hi". The "90" from the limit input has merged into the keyword field.
What is the root cause of that problem?
The root cause is in the
buildQueryStringFromFilterFormValuesfunction insrc/libs/SearchQueryUtils.ts. When converting form values to a query string, the limit value is added without any validation or sanitization:App/src/libs/SearchQueryUtils.ts
Lines 749 to 752 in eb7deee
When a user enters
10 90as the limit value, this produceslimit:10 90in the query string. When the search parser (searchParser.peggy) parses this query:limit:10is parsed as a default filter with value1090becomes a free text filter, which is treated as a keywordApp/src/libs/SearchParser/searchParser.peggy
Lines 189 to 199 in eb7deee
The parser's
identifierrule only accepts comma-separated values, not space-separated ones:App/src/libs/SearchParser/searchParser.peggy
Lines 276 to 288 in eb7deee
So when the saved search is loaded back and
buildFilterFormValuesFromQueryreconstructs the form values, the90is combined with the existing keywordhi, resulting in "hi 90".What changes do you think we should make in order to solve the problem?
Sanitize the limit value in
buildQueryStringFromFilterFormValuesbefore adding it to the query string. Sincelimitmust be a positive integer (as validated inbuildSearchQueryJSONat lines 445-448), we should extract only the first valid positive integer from the input:In
src/libs/SearchQueryUtils.ts, modify the limit handling around line 749:This ensures:
What alternative solutions did you explore? (Optional)
NA
14 remaining items
[-]Expense - Limit value merges with keyword when saved with space[/-][+][Due for payment 2026-02-23] Expense - Limit value merges with keyword when saved with space[/+]melvin-bot commentedon Feb 16, 2026
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Feb 16, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.19-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2026-02-23. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Feb 23, 2026
Issue is ready for payment but no BZ is assigned. @sonialiap you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!
sonialiap commentedon Feb 23, 2026
Payment summary:
Part of a project, no payment needed on this issue
@ShridharGoel $250 please request through NewDot@TaduJR $250 offer sent in upworkShridharGoel commentedon Feb 23, 2026
@trjExpensify Is this considered a part of the insights project or is it separate?
trjExpensify commentedon Feb 23, 2026
Yeah, this is part of Insights as clean up for the
Limitfilter. We don't need to process payments here. 👍sonialiap commentedon Feb 24, 2026
Updating Payment summary to no payment needed