Skip to content

Commit 9eaa84a

Browse files
authored
Merge pull request Expensify#69829 from ShridharGoel/tagsSearch
Use available tags count based on selection in TagPicker component
2 parents 27fc4e7 + f9fdedd commit 9eaa84a

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/components/TagPicker/index.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import useLocalize from '@hooks/useLocalize';
55
import useOnyx from '@hooks/useOnyx';
66
import useThemeStyles from '@hooks/useThemeStyles';
77
import {getHeaderMessageForNonUserList} from '@libs/OptionsListUtils';
8-
import {getCountOfEnabledTagsOfList, getTagList} from '@libs/PolicyUtils';
8+
import {getTagList} from '@libs/PolicyUtils';
99
import type {OptionData} from '@libs/ReportUtils';
1010
import type {SelectedTagOption} from '@libs/TagsOptionsListUtils';
1111
import {getTagListSections} from '@libs/TagsOptionsListUtils';
@@ -64,10 +64,6 @@ function TagPicker({
6464

6565
const policyRecentlyUsedTagsList = useMemo(() => policyRecentlyUsedTags?.[tagListName] ?? [], [policyRecentlyUsedTags, tagListName]);
6666
const policyTagList = getTagList(policyTags, tagListIndex);
67-
const policyTagsCount = getCountOfEnabledTagsOfList(policyTagList.tags);
68-
const isTagsCountBelowThreshold = policyTagsCount < CONST.STANDARD_LIST_ITEM_LIMIT;
69-
70-
const shouldShowTextInput = !isTagsCountBelowThreshold;
7167

7268
const selectedOptions: SelectedTagOption[] = useMemo(() => {
7369
if (!selectedTag) {
@@ -110,6 +106,11 @@ function TagPicker({
110106
return [...selectedOptions, ...Object.values(policyTagList.tags).filter((policyTag) => policyTag.enabled && !selectedNames.includes(policyTag.name))];
111107
}, [shouldShowDisabledAndSelectedOption, hasDependentTags, selectedOptions, policyTagList.tags, transactionTag, tagListIndex]);
112108

109+
const availableTagsCount = Array.isArray(enabledTags) ? enabledTags.length : Object.keys(enabledTags).length;
110+
const isTagsCountBelowThreshold = availableTagsCount < CONST.STANDARD_LIST_ITEM_LIMIT;
111+
112+
const shouldShowTextInput = !isTagsCountBelowThreshold;
113+
113114
const sections = useMemo(() => {
114115
const tagSections = getTagListSections({
115116
searchValue,

0 commit comments

Comments
 (0)