Skip to content

Commit b13a18b

Browse files
authored
Merge pull request #76840 from Expensify/jsenyitko-remove-uncategorized
Remove 'Uncategorized' from the filters when theres no category
2 parents f8bb2a8 + 91ca92f commit b13a18b

File tree

7 files changed

+9
-11
lines changed

7 files changed

+9
-11
lines changed

src/CONST/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6822,7 +6822,8 @@ const CONST = {
68226822
BEFORE_PREFIX: 'reportFieldBefore-',
68236823
},
68246824
TAG_EMPTY_VALUE: 'none',
6825-
CATEGORY_EMPTY_VALUE: 'none,Uncategorized',
6825+
CATEGORY_EMPTY_VALUE: 'none',
6826+
CATEGORY_DEFAULT_VALUE: 'Uncategorized',
68266827
SEARCH_ROUTER_ITEM_TYPE: {
68276828
CONTEXTUAL_SUGGESTION: 'contextualSuggestion',
68286829
AUTOCOMPLETE_SUGGESTION: 'autocompleteSuggestion',

src/libs/CategoryUtils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@ function isCategoryMissing(category: string | undefined): boolean {
9898
if (!category) {
9999
return true;
100100
}
101-
const emptyCategories = CONST.SEARCH.CATEGORY_EMPTY_VALUE.split(',');
102101

103-
return emptyCategories.includes(category ?? '');
102+
return category === CONST.SEARCH.CATEGORY_EMPTY_VALUE || category === CONST.SEARCH.CATEGORY_DEFAULT_VALUE;
104103
}
105104

106105
function isCategoryDescriptionRequired(policyCategories: PolicyCategories | undefined, category: string | undefined, areRulesEnabled: boolean | undefined): boolean {

src/libs/SearchAutocompleteUtils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ const userFriendlyStatusList = Object.values({
136136

137137
/**
138138
* @private
139+
* Determines if a specific value in the search syntax can/should be highlighted as valid or not
139140
*/
140141
function filterOutRangesWithCorrectValue(
141142
range: SearchAutocompleteQueryRange,
@@ -193,7 +194,7 @@ function filterOutRangesWithCorrectValue(
193194
case CONST.SEARCH.SYNTAX_FILTER_KEYS.ACTION:
194195
return actionList.includes(range.value);
195196
case CONST.SEARCH.SYNTAX_FILTER_KEYS.CATEGORY:
196-
return categoryList.get().includes(range.value);
197+
return categoryList.get().includes(range.value) || range.value === CONST.SEARCH.CATEGORY_EMPTY_VALUE;
197198
case CONST.SEARCH.SYNTAX_FILTER_KEYS.TAG:
198199
return tagList.get().includes(range.value);
199200
case CONST.SEARCH.SYNTAX_ROOT_KEYS.GROUP_BY:

src/libs/SearchQueryUtils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,9 +834,7 @@ function buildFilterFormValuesFromQuery(
834834
.map((item) => Object.values(item ?? {}).map((category) => category.name))
835835
.flat();
836836
const uniqueCategories = new Set(categories);
837-
const emptyCategories = CONST.SEARCH.CATEGORY_EMPTY_VALUE.split(',');
838-
const hasEmptyCategoriesInFilter = emptyCategories.every((category) => filterValues.includes(category));
839-
// We split CATEGORY_EMPTY_VALUE into individual values to detect both are present in filterValues.
837+
const hasEmptyCategoriesInFilter = filterValues.includes(CONST.SEARCH.CATEGORY_EMPTY_VALUE);
840838
// If empty categories are found, append the CATEGORY_EMPTY_VALUE to filtersForm.
841839
filtersForm[key as typeof filterKey] = filterValues.filter((name) => uniqueCategories.has(name)).concat(hasEmptyCategoriesInFilter ? [CONST.SEARCH.CATEGORY_EMPTY_VALUE] : []);
842840
}

src/libs/SearchUIUtils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,8 +2508,7 @@ function getColumnsToShow(
25082508
}
25092509

25102510
const category = getCategory(transaction);
2511-
const categoryEmptyValues = CONST.SEARCH.CATEGORY_EMPTY_VALUE.split(',');
2512-
if (category !== '' && !categoryEmptyValues.includes(category)) {
2511+
if (category !== '' && category !== CONST.SEARCH.CATEGORY_EMPTY_VALUE) {
25132512
columns[CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY] = true;
25142513
}
25152514

tests/unit/Search/SearchQueryUtilsTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ describe('SearchQueryUtils', () => {
394394
expect(result).toEqual({
395395
type: 'expense',
396396
status: CONST.SEARCH.STATUS.EXPENSE.ALL,
397-
category: ['Maintenance', 'none,Uncategorized'],
397+
category: ['Maintenance', 'none'],
398398
});
399399
});
400400

tests/unit/Search/SearchUIUtilsTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2735,7 +2735,7 @@ describe('SearchUIUtils', () => {
27352735
merchant: '',
27362736
modifiedMerchant: 'Modified Merchant',
27372737
comment: {comment: ''},
2738-
category: 'Uncategorized', // This is in CONST.SEARCH.CATEGORY_EMPTY_VALUE
2738+
category: 'none', // This is in CONST.SEARCH.CATEGORY_EMPTY_VALUE
27392739
tag: CONST.SEARCH.TAG_EMPTY_VALUE, // This is the empty tag value
27402740
accountID: adminAccountID,
27412741
managerID: adminAccountID,

0 commit comments

Comments
 (0)