Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo
);

const submitSearch = useCallback(
(queryString: SearchQueryString) => {
(queryString: SearchQueryString, shouldSkipAmountConversion = false) => {
const queryWithSubstitutions = getQueryWithSubstitutions(queryString, autocompleteSubstitutions);
const updatedQuery = getQueryWithUpdatedValues(queryWithSubstitutions);
const updatedQuery = getQueryWithUpdatedValues(queryWithSubstitutions, shouldSkipAmountConversion);

if (!updatedQuery) {
return;
Expand Down Expand Up @@ -268,7 +268,7 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo
timestamp: endTime,
});
} else if (item.searchItemType === CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.SEARCH) {
submitSearch(item.searchQuery);
submitSearch(item.searchQuery, item.keyForList !== 'findItem');

const endTime = Date.now();
Log.info('[CMD_K_DEBUG] Page search submitted', false, {
Expand Down
11 changes: 8 additions & 3 deletions src/libs/SearchQueryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,11 @@ function getFilters(queryJSON: SearchQueryJSON) {
* - for `AMOUNT` it formats value to "backend" amount
* - for personal filters it tries to substitute any user emails with accountIDs
*/
function getUpdatedFilterValue(filterName: ValueOf<typeof CONST.SEARCH.SYNTAX_FILTER_KEYS>, filterValue: string | string[]) {
function getUpdatedFilterValue(filterName: ValueOf<typeof CONST.SEARCH.SYNTAX_FILTER_KEYS>, filterValue: string | string[], shouldSkipAmountConversion = false) {
if (AMOUNT_FILTER_KEYS.includes(filterName as SearchAmountFilterKeys)) {
if (shouldSkipAmountConversion) {
return filterValue;
}
if (typeof filterValue === 'string') {
const backendAmount = convertToBackendAmount(Number(filterValue));
return Number.isNaN(backendAmount) ? filterValue : backendAmount.toString();
Expand Down Expand Up @@ -1141,15 +1144,17 @@ function traverseAndUpdatedQuery(queryJSON: SearchQueryJSON, computeNodeValue: (
* Returns new string query, after parsing it and traversing to update some filter values.
* If there are any personal emails, it will try to substitute them with accountIDs
*/
function getQueryWithUpdatedValues(query: string) {
function getQueryWithUpdatedValues(query: string, shouldSkipAmountConversion = false) {
const queryJSON = buildSearchQueryJSON(query);

if (!queryJSON) {
Log.alert(`${CONST.ERROR.ENSURE_BUG_BOT} user query failed to parse`, {}, false);
return;
}

const standardizedQuery = traverseAndUpdatedQuery(queryJSON, getUpdatedFilterValue);
const computeNodeValue = (left: ValueOf<typeof CONST.SEARCH.SYNTAX_FILTER_KEYS>, right: string | string[]) => getUpdatedFilterValue(left, right, shouldSkipAmountConversion);

const standardizedQuery = traverseAndUpdatedQuery(queryJSON, computeNodeValue);
return buildSearchQueryString(standardizedQuery);
}

Expand Down
Loading