diff --git a/src/CONST/index.ts b/src/CONST/index.ts index dda87c85a8ab6..fdda6fefd2862 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -6822,7 +6822,8 @@ const CONST = { BEFORE_PREFIX: 'reportFieldBefore-', }, TAG_EMPTY_VALUE: 'none', - CATEGORY_EMPTY_VALUE: 'none,Uncategorized', + CATEGORY_EMPTY_VALUE: 'none', + CATEGORY_DEFAULT_VALUE: 'Uncategorized', SEARCH_ROUTER_ITEM_TYPE: { CONTEXTUAL_SUGGESTION: 'contextualSuggestion', AUTOCOMPLETE_SUGGESTION: 'autocompleteSuggestion', diff --git a/src/libs/CategoryUtils.ts b/src/libs/CategoryUtils.ts index fb87060ed1fae..30f44eeb625d1 100644 --- a/src/libs/CategoryUtils.ts +++ b/src/libs/CategoryUtils.ts @@ -98,9 +98,8 @@ function isCategoryMissing(category: string | undefined): boolean { if (!category) { return true; } - const emptyCategories = CONST.SEARCH.CATEGORY_EMPTY_VALUE.split(','); - return emptyCategories.includes(category ?? ''); + return category === CONST.SEARCH.CATEGORY_EMPTY_VALUE || category === CONST.SEARCH.CATEGORY_DEFAULT_VALUE; } function isCategoryDescriptionRequired(policyCategories: PolicyCategories | undefined, category: string | undefined, areRulesEnabled: boolean | undefined): boolean { diff --git a/src/libs/SearchAutocompleteUtils.ts b/src/libs/SearchAutocompleteUtils.ts index e3ec6741b10ad..6786a156beb91 100644 --- a/src/libs/SearchAutocompleteUtils.ts +++ b/src/libs/SearchAutocompleteUtils.ts @@ -136,6 +136,7 @@ const userFriendlyStatusList = Object.values({ /** * @private + * Determines if a specific value in the search syntax can/should be highlighted as valid or not */ function filterOutRangesWithCorrectValue( range: SearchAutocompleteQueryRange, @@ -193,7 +194,7 @@ function filterOutRangesWithCorrectValue( case CONST.SEARCH.SYNTAX_FILTER_KEYS.ACTION: return actionList.includes(range.value); case CONST.SEARCH.SYNTAX_FILTER_KEYS.CATEGORY: - return categoryList.get().includes(range.value); + return categoryList.get().includes(range.value) || range.value === CONST.SEARCH.CATEGORY_EMPTY_VALUE; case CONST.SEARCH.SYNTAX_FILTER_KEYS.TAG: return tagList.get().includes(range.value); case CONST.SEARCH.SYNTAX_ROOT_KEYS.GROUP_BY: diff --git a/src/libs/SearchQueryUtils.ts b/src/libs/SearchQueryUtils.ts index bdc8c3142113a..7291b0397be0a 100644 --- a/src/libs/SearchQueryUtils.ts +++ b/src/libs/SearchQueryUtils.ts @@ -834,9 +834,7 @@ function buildFilterFormValuesFromQuery( .map((item) => Object.values(item ?? {}).map((category) => category.name)) .flat(); const uniqueCategories = new Set(categories); - const emptyCategories = CONST.SEARCH.CATEGORY_EMPTY_VALUE.split(','); - const hasEmptyCategoriesInFilter = emptyCategories.every((category) => filterValues.includes(category)); - // We split CATEGORY_EMPTY_VALUE into individual values to detect both are present in filterValues. + const hasEmptyCategoriesInFilter = filterValues.includes(CONST.SEARCH.CATEGORY_EMPTY_VALUE); // If empty categories are found, append the CATEGORY_EMPTY_VALUE to filtersForm. filtersForm[key as typeof filterKey] = filterValues.filter((name) => uniqueCategories.has(name)).concat(hasEmptyCategoriesInFilter ? [CONST.SEARCH.CATEGORY_EMPTY_VALUE] : []); } diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index b7460981d5e31..1757b4f2616a6 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -2508,8 +2508,7 @@ function getColumnsToShow( } const category = getCategory(transaction); - const categoryEmptyValues = CONST.SEARCH.CATEGORY_EMPTY_VALUE.split(','); - if (category !== '' && !categoryEmptyValues.includes(category)) { + if (category !== '' && category !== CONST.SEARCH.CATEGORY_EMPTY_VALUE) { columns[CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY] = true; } diff --git a/tests/unit/Search/SearchQueryUtilsTest.ts b/tests/unit/Search/SearchQueryUtilsTest.ts index 66b95d9195022..2e3b935d15f63 100644 --- a/tests/unit/Search/SearchQueryUtilsTest.ts +++ b/tests/unit/Search/SearchQueryUtilsTest.ts @@ -394,7 +394,7 @@ describe('SearchQueryUtils', () => { expect(result).toEqual({ type: 'expense', status: CONST.SEARCH.STATUS.EXPENSE.ALL, - category: ['Maintenance', 'none,Uncategorized'], + category: ['Maintenance', 'none'], }); }); diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index 6abd283de26b0..aaa53367f92ce 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -2735,7 +2735,7 @@ describe('SearchUIUtils', () => { merchant: '', modifiedMerchant: 'Modified Merchant', comment: {comment: ''}, - category: 'Uncategorized', // This is in CONST.SEARCH.CATEGORY_EMPTY_VALUE + category: 'none', // This is in CONST.SEARCH.CATEGORY_EMPTY_VALUE tag: CONST.SEARCH.TAG_EMPTY_VALUE, // This is the empty tag value accountID: adminAccountID, managerID: adminAccountID,