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
3 changes: 2 additions & 1 deletion src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 1 addition & 2 deletions src/libs/CategoryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/libs/SearchAutocompleteUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions src/libs/SearchQueryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] : []);
}
Expand Down
3 changes: 1 addition & 2 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Search/SearchQueryUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ describe('SearchQueryUtils', () => {
expect(result).toEqual({
type: 'expense',
status: CONST.SEARCH.STATUS.EXPENSE.ALL,
category: ['Maintenance', 'none,Uncategorized'],
category: ['Maintenance', 'none'],
});
});

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Search/SearchUIUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading