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
7 changes: 7 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6489,6 +6489,13 @@ const CONST = {
BILLABLE: 'billable',
ACTION: 'action',
},

// Maps an internal search value to the user friendly display text, e.g. `perDiem` -> `per-diem`
get SEARCH_USER_FRIENDLY_VALUES_MAP() {
return {
[this.TRANSACTION_TYPE.PER_DIEM]: 'per-diem',
};
},
DATE_MODIFIERS: {
ON: 'On',
AFTER: 'After',
Expand Down
11 changes: 10 additions & 1 deletion src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ import {
getQueryWithoutAutocompletedPart,
parseForAutocomplete,
} from '@libs/SearchAutocompleteUtils';
import {buildSearchQueryJSON, buildUserReadableQueryString, getQueryWithoutFilters, getUserFriendlyKey, sanitizeSearchValue, shouldHighlight} from '@libs/SearchQueryUtils';
import {
buildSearchQueryJSON,
buildUserReadableQueryString,
getQueryWithoutFilters,
getUserFriendlyKey,
getUserFriendlyValue,
sanitizeSearchValue,
shouldHighlight,
} from '@libs/SearchQueryUtils';
import {getDatePresets} from '@libs/SearchUIUtils';
import StringUtils from '@libs/StringUtils';
import Timing from '@userActions/Timing';
Expand Down Expand Up @@ -382,6 +390,7 @@ function SearchAutocompleteList(
}
case CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPENSE_TYPE: {
const filteredExpenseTypes = expenseTypes
.map((value) => getUserFriendlyValue(value))
.filter((expenseType) => expenseType.includes(autocompleteValue.toLowerCase()) && !alreadyAutocompletedKeys.includes(expenseType))
.sort();

Expand Down
2 changes: 2 additions & 0 deletions src/components/Search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ type SearchFilterKey =
| typeof CONST.SEARCH.SYNTAX_ROOT_KEYS.GROUP_BY;

type UserFriendlyKey = ValueOf<typeof CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS>;
type UserFriendlyValue = ValueOf<typeof CONST.SEARCH.SEARCH_USER_FRIENDLY_VALUES_MAP>;

type QueryFilters = Array<{
key: SearchFilterKey;
Expand Down Expand Up @@ -211,4 +212,5 @@ export type {
SingularSearchStatus,
SearchDatePreset,
SearchWithdrawalType,
UserFriendlyValue,
};
5 changes: 4 additions & 1 deletion src/libs/SearchAutocompleteUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import CONST from '@src/CONST';
import type {PolicyCategories, PolicyTagLists, RecentlyUsedCategories, RecentlyUsedTags} from '@src/types/onyx';
import {getTagNamesFromTagsLists} from './PolicyUtils';
import {parse} from './SearchParser/autocompleteParser';
import {getUserFriendlyValue} from './SearchQueryUtils';

/**
* Parses given query using the autocomplete parser.
Expand Down Expand Up @@ -109,6 +110,8 @@ function getAutocompleteQueryWithComma(prevQuery: string, newQuery: string) {
return newQuery;
}

const userFriendlyExpenseTypeList = Object.values(CONST.SEARCH.TRANSACTION_TYPE).map((value) => getUserFriendlyValue(value));

/**
* @private
*/
Expand All @@ -123,7 +126,7 @@ function filterOutRangesWithCorrectValue(
'worklet';

const typeList = Object.values(CONST.SEARCH.DATA_TYPES) as string[];
const expenseTypeList = Object.values(CONST.SEARCH.TRANSACTION_TYPE) as string[];
const expenseTypeList = userFriendlyExpenseTypeList;
const withdrawalTypeList = Object.values(CONST.SEARCH.WITHDRAWAL_TYPE) as string[];
const statusList = Object.values({
...CONST.SEARCH.STATUS.EXPENSE,
Expand Down
Loading
Loading