You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-06-29] [$250] Spend - Tag filter is present when account has no tag #93568
Version Number: 9.4.7-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: EDGE https://github.com/Expensify/Expensify/issues/447655 Email or phone of affected tester (no customers): undefined Issue reported by: Applause Internal Team
Action Performed:
Go to staging.new.expensify.com
Create a new account.
Create a workspace.
Go to workspace settings > More features.
Enable Tags.
Go to workspace settings > Categories.
Click More > Settings.
Disable Members must categorize all expenses.
Delete all the categories.
Go to Spend > Expenses.
Click Filters.
Find Category and Tag filter
Expected Result:
Category and Tag filter should be hidden when account has no category and tag.
Actual Result:
When account has no category and tag, Category filter is hidden, but Tag filter is present.
The third argument (singlePolicyCondition) is !!selectedPolicyTagLists. But selectedPolicyTagLists comes from getAllPolicyValues, which always returns an array ([] at minimum) — so !!selectedPolicyTagLists is always true.
Because singlePolicyCondition is always true, the whole expression collapses to just areTagsEnabled. So the Tag filter shows whenever Tags is enabled, regardless of whether any tags actually exist.
The Category filter does not have this bug because its equivalent condition correctly checks array length (line 340): selectedPolicyCategories?.length > 0. That is why Category is hidden after deletion but Tag is not.
What changes do you think we should make in order to solve the problem?
Replace the always-truthy !!selectedPolicyTagLists with a check that the selected policies actually contain tag entries, mirroring the Category filter's selectedPolicyCategories?.length > 0 pattern.
This makes the Tag filter's singlePolicyCondition semantically match the Category filter's: show the filter only when tag entries actually exist in the selected policy.
What alternative solutions did you explore? (Optional)
Using selectedPolicyTagLists.length > 0 alone — a closer mirror to the Category line — is insufficient because a policy can have a tag-list container with zero tags inside it, so .length > 0 could still be true with no actual tags. Checking the nested tags content is more correct.
📣 @Ayesha-Ashraf-Dev! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
The third argument (singlePolicyCondition) is !!selectedPolicyTagLists. But selectedPolicyTagLists comes from getAllPolicyValues, which always returns an array ([] at minimum). An array — even an empty one — is always truthy, so !!selectedPolicyTagLists is always true.
Because singlePolicyCondition is always true, the whole expression collapses to just areTagsEnabled. So the Tag filter shows whenever the Tags feature is enabled, regardless of whether any tags actually exist — which is exactly the reported behavior (Tags enabled in step 5, no tags created → filter still shows).
The Category filter does not have this bug because its equivalent condition correctly checks array length (line 340): selectedPolicyCategories?.length > 0. That's why Category is hidden but Tag is not.
What changes do you think we should make in order to solve the problem?
Replace the always-truthy !!selectedPolicyTagLists with a check that the selected policies actually contain tags, mirroring the existing hasTagsSelector logic.
Suggested change in src/hooks/useAdvancedSearchFilters.ts
This makes the Tag filter's singlePolicyCondition semantically match the Category filter's (selectedPolicyCategories?.length > 0): show the filter only when the relevant entities actually exist.
What alternative solutions did you explore? (Optional)
Alternatives considered
Simply use selectedPolicyTagLists.length > 0 — closer mirror to the Category line, but a policy can have a tag-list container with zero tags inside it, so .length > 0 could still be true with no actual tags. Checking the nested tags content (as above) is more correct.
Drop the singlePolicyCondition and rely only on hasTags — would fix this report, but loses the intended "show the filter for the specific selected workspace" broadening that the Category filter also relies on.
Confidence: High — the bug is a pure logic error confirmed in code: getAllPolicyValues never returns a falsy value, so !!selectedPolicyTagLists can never be false. No production logs needed.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/blob/1765e75a02a6990312f107ea45f848998ed1178f/src/hooks/useAdvancedSearchFilters.ts#L341) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
🚨 Edited by proposal-police: This proposal was edited at 2026-06-15 09:54:27 UTC.
Proposal
What is the root cause of that problem?
The Tag filter visibility logic checks the wrong thing after tags are deleted.
When tags are deleted, deletePolicyTags() does not immediately remove them from Onyx. It first marks each deleted tag with pendingAction: DELETE and enabled: false in optimistic data:
That means a workspace with an empty or pending-delete tag container can still make the Tag filter visible.
History supports this RCA: PR #84679 / commit f62d5a2 fixed the same selected-workspace empty-data problem inside the Tag and Category filter pages by avoiding fallback to all workspaces when a selected workspace had no values:
This issue is the same availability bug one level earlier: the filter row itself is still shown because the hook counts deleted/empty tag data as available.
What changes do you think we should make in order to solve the problem?
Make Tag availability use the same “available value” definition as Category and the workspace tag pages: a tag should count only if it is not pending deletion.
Also make the selected-policy case depend on the selected policies’ available tags, instead of the existence of a policyTags_<policyID> object.
Small diff excerpt:
+function hasAvailableTags(policyTagLists: PolicyTagLists | undefined): boolean {+ return Object.values(policyTagLists ?? {}).some((tagList) =>+ Object.values(tagList.tags ?? {}).some((tag) => tag.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE),+ );+}
const hasTagsSelector = (allPolicyTagLists: OnyxCollection<PolicyTagLists>) => {
for (const policyTagList of Object.values(allPolicyTagLists ?? {})) {
- if (!policyTagList) {- continue;- }- for (const tagList of Object.values(policyTagList)) {- if (Object.keys(tagList.tags ?? {}).length > 0) {- return true;- }+ if (hasAvailableTags(policyTagList)) {+ return true;
}
}
return false;
};
Then use selected-policy availability when a workspace filter is active:
No workspace selected: behavior still depends on whether any workspace has available tags.
Workspace selected: Tag only appears if at least one selected workspace has available tags.
Tags enabled but all tags deleted: Tag is hidden, matching Category behavior.
Tags pending deletion: Tag is hidden immediately, matching existing workspace tag UI.
The existing areTagsEnabled feature flag still gates the filter, so disabled Tags workspaces stay unchanged.
We should also add a focused test around useAdvancedSearchFilters or its extracted availability helpers for these cases: no tags, pending-delete tags, selected workspace with tags, selected workspace without tags while another workspace has tags.
What alternative solutions did you explore? (Optional)
We could hide deleted tags only inside SearchFiltersTagPage, but that would still leave a Tag row that opens a mostly empty picker. The root problem is the filter visibility decision in useAdvancedSearchFilters, so fixing the availability check there is the smaller and safer fix.
🚨 Edited by proposal-police: This proposal was edited at 2026-06-15 09:59:23 UTC.
Proposal
What is the root cause of that problem?
The advanced filter list is built by useAdvancedSearchFilters(). Category is hidden correctly because its visibility check only passes the selected-policy override when selected policies actually have category data.
So !!selectedPolicyTagLists is true even when no workspace filter is selected, and it is also true when a selected workspace only has an empty tag-list object with no tag values. When Tags are enabled, that truthy override keeps the Tag filter visible. The Tag page then adds the built-in No tag option before adding real tag names, so the user sees a Tag filter with only No tag.
What changes do you think we should make in order to solve the problem?
Update src/hooks/useAdvancedSearchFilters.ts so the Tag filter override checks for actual tag entries instead of checking whether the returned array object exists.
We can reuse the existing PolicyUtils.hasTags() helper or extract the traversal already used by hasTagsSelector, then derive something like hasSelectedPolicyTags = selectedPolicyTagLists.some(hasPolicyTags). Use that value in shouldDisplayTagFilter instead of !!selectedPolicyTagLists.
This keeps the change scoped to client-side filter visibility. It should not change the Tag picker's No tag option, the existing -has:tag query serialization, or backend/API behavior.
Please update tests/unit/hooks/useAdvancedSearchFilters.test.ts so the current empty-tag-list case expects Tag to be hidden. Also cover:
Tags enabled with no selected workspace and no real tags: Tag hidden.
Tags enabled with a selected workspace whose tag list has no tag values: Tag hidden.
Tags enabled with at least one real tag value: Tag visible.
What alternative solutions did you explore? (Optional)
I considered removing No tag from the Tag picker when there are no real tags, but that would only hide the symptom after the bad filter row is already visible. The correct fix is to prevent the Tag filter row from being shown when there are no real tag values to filter by.
changed the title [-]Spend - Tag filter is present when account has no tag[/-][+][$250] Spend - Tag filter is present when account has no tag[/+]on Jun 15, 2026
Activity
Ayesha-Ashraf-Dev commentedon Jun 15, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-06-15 10:00:38 UTC.
Contributor details
Your Expensify account email: ayeshaashraf0091@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/ayeshaa337
Proposal
[Updated]
What is the root cause of that problem?
The Tag filter's visibility is computed in
useAdvancedSearchFilters.ts:341:The third argument (
singlePolicyCondition) is!!selectedPolicyTagLists. ButselectedPolicyTagListscomes fromgetAllPolicyValues, which always returns an array ([]at minimum) — so!!selectedPolicyTagListsis alwaystrue.Looking at
shouldDisplayFilter:Because
singlePolicyConditionis alwaystrue, the whole expression collapses to justareTagsEnabled. So the Tag filter shows whenever Tags is enabled, regardless of whether any tags actually exist.The Category filter does not have this bug because its equivalent condition correctly checks array length (line 340):
selectedPolicyCategories?.length > 0. That is why Category is hidden after deletion but Tag is not.What changes do you think we should make in order to solve the problem?
Replace the always-truthy
!!selectedPolicyTagListswith a check that the selected policies actually contain tag entries, mirroring the Category filter'sselectedPolicyCategories?.length > 0pattern.In
src/hooks/useAdvancedSearchFilters.ts:This makes the Tag filter's
singlePolicyConditionsemantically match the Category filter's: show the filter only when tag entries actually exist in the selected policy.What alternative solutions did you explore? (Optional)
Using
selectedPolicyTagLists.length > 0alone — a closer mirror to the Category line — is insufficient because a policy can have a tag-list container with zero tags inside it, so.length > 0could still betruewith no actual tags. Checking the nestedtagscontent is more correct.melvin-bot commentedon Jun 15, 2026
📣 @Ayesha-Ashraf-Dev! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Format:
MelvinBot commentedon Jun 15, 2026
Proposal
What is the root cause of that problem?
The Tag filter's visibility is computed in
useAdvancedSearchFilters.ts:341:The third argument (
singlePolicyCondition) is!!selectedPolicyTagLists. ButselectedPolicyTagListscomes fromgetAllPolicyValues, which always returns an array ([]at minimum). An array — even an empty one — is always truthy, so!!selectedPolicyTagListsis alwaystrue.Looking at
shouldDisplayFilter:Because
singlePolicyConditionis alwaystrue, the whole expression collapses to justareTagsEnabled. So the Tag filter shows whenever the Tags feature is enabled, regardless of whether any tags actually exist — which is exactly the reported behavior (Tags enabled in step 5, no tags created → filter still shows).The Category filter does not have this bug because its equivalent condition correctly checks array length (line 340):
selectedPolicyCategories?.length > 0. That's why Category is hidden but Tag is not.What changes do you think we should make in order to solve the problem?
Replace the always-truthy
!!selectedPolicyTagListswith a check that the selected policies actually contain tags, mirroring the existinghasTagsSelectorlogic.Suggested change in
src/hooks/useAdvancedSearchFilters.tsThis makes the Tag filter's
singlePolicyConditionsemantically match the Category filter's (selectedPolicyCategories?.length > 0): show the filter only when the relevant entities actually exist.What alternative solutions did you explore? (Optional)
Alternatives considered
selectedPolicyTagLists.length > 0— closer mirror to the Category line, but a policy can have a tag-list container with zero tags inside it, so.length > 0could still be true with no actual tags. Checking the nestedtagscontent (as above) is more correct.singlePolicyConditionand rely only onhasTags— would fix this report, but loses the intended "show the filter for the specific selected workspace" broadening that the Category filter also relies on.Confidence: High — the bug is a pure logic error confirmed in code:
getAllPolicyValuesnever returns a falsy value, so!!selectedPolicyTagListscan never befalse. No production logs needed.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/blob/1765e75a02a6990312f107ea45f848998ed1178f/src/hooks/useAdvancedSearchFilters.ts#L341)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
mukhrr commentedon Jun 15, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-06-15 09:54:27 UTC.
Proposal
What is the root cause of that problem?
The Tag filter visibility logic checks the wrong thing after tags are deleted.
When tags are deleted,
deletePolicyTags()does not immediately remove them from Onyx. It first marks each deleted tag withpendingAction: DELETEandenabled: falsein optimistic data:App/src/libs/actions/Policy/Tag.ts
Lines 459 to 475 in aafd782
Other tag UIs already treat those tags as unavailable. For example, workspace tag selection filters out tags with
pendingAction: DELETE:App/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx
Line 93 in aafd782
And the workspace tags page uses the same idea when deciding whether there are visible tags:
App/src/pages/workspace/tags/WorkspaceTagsPage.tsx
Line 544 in aafd782
The advanced search Category filter already follows this pattern: it only considers categories whose
pendingActionis notDELETE:App/src/hooks/useAdvancedSearchFilters.ts
Lines 194 to 199 in aafd782
But the Tag filter does not.
hasTagsSelector()only checks whethertagList.tagshas keys, so tags pending deletion still count as available:App/src/hooks/useAdvancedSearchFilters.ts
Lines 285 to 297 in aafd782
Then the selected-policy condition also only checks whether
selectedPolicyTagListsexists:App/src/hooks/useAdvancedSearchFilters.ts
Lines 327 to 341 in aafd782
That means a workspace with an empty or pending-delete tag container can still make the Tag filter visible.
History supports this RCA: PR #84679 / commit
f62d5a2fixed the same selected-workspace empty-data problem inside the Tag and Category filter pages by avoiding fallback to all workspaces when a selected workspace had no values:f62d5a2
This issue is the same availability bug one level earlier: the filter row itself is still shown because the hook counts deleted/empty tag data as available.
What changes do you think we should make in order to solve the problem?
Make Tag availability use the same “available value” definition as Category and the workspace tag pages: a tag should count only if it is not pending deletion.
Also make the selected-policy case depend on the selected policies’ available tags, instead of the existence of a
policyTags_<policyID>object.Small diff excerpt:
Then use selected-policy availability when a workspace filter is active:
const selectedPolicyTagLists = getAllPolicyValues(policyID, ONYXKEYS.COLLECTION.POLICY_TAGS, allPolicyTagLists); const [hasTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS, {selector: hasTagsSelector}); +const hasSelectedPolicyTags = selectedPolicyTagLists.some(hasAvailableTags); +const shouldCheckSelectedPolicies = !!policyID?.length; -const shouldDisplayTagFilter = shouldDisplayFilter(hasTags ? 1 : 0, policyDerived?.areTagsEnabled ?? false, !!selectedPolicyTagLists); +const shouldDisplayTagFilter = shouldDisplayFilter( + shouldCheckSelectedPolicies ? (hasSelectedPolicyTags ? 1 : 0) : (hasTags ? 1 : 0), + policyDerived?.areTagsEnabled ?? false, +);This avoids regression because:
areTagsEnabledfeature flag still gates the filter, so disabled Tags workspaces stay unchanged.We should also add a focused test around
useAdvancedSearchFiltersor its extracted availability helpers for these cases: no tags, pending-delete tags, selected workspace with tags, selected workspace without tags while another workspace has tags.What alternative solutions did you explore? (Optional)
We could hide deleted tags only inside
SearchFiltersTagPage, but that would still leave a Tag row that opens a mostly empty picker. The root problem is the filter visibility decision inuseAdvancedSearchFilters, so fixing the availability check there is the smaller and safer fix.KJ21-ENG commentedon Jun 15, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-06-15 09:59:23 UTC.
Proposal
What is the root cause of that problem?
The advanced filter list is built by
useAdvancedSearchFilters(). Category is hidden correctly because its visibility check only passes the selected-policy override when selected policies actually have category data.Tag uses a different override:
App/src/hooks/useAdvancedSearchFilters.ts
Lines 326 to 341 in 1765e75
selectedPolicyTagListscomes fromgetAllPolicyValues(), which always returns an array:App/src/libs/SearchQueryUtils.ts
Lines 992 to 1001 in 1765e75
So
!!selectedPolicyTagListsis true even when no workspace filter is selected, and it is also true when a selected workspace only has an empty tag-list object with no tag values. When Tags are enabled, that truthy override keeps the Tag filter visible. The Tag page then adds the built-inNo tagoption before adding real tag names, so the user sees a Tag filter with onlyNo tag.What changes do you think we should make in order to solve the problem?
Update
src/hooks/useAdvancedSearchFilters.tsso the Tag filter override checks for actual tag entries instead of checking whether the returned array object exists.We can reuse the existing
PolicyUtils.hasTags()helper or extract the traversal already used byhasTagsSelector, then derive something likehasSelectedPolicyTags = selectedPolicyTagLists.some(hasPolicyTags). Use that value inshouldDisplayTagFilterinstead of!!selectedPolicyTagLists.This keeps the change scoped to client-side filter visibility. It should not change the Tag picker's
No tagoption, the existing-has:tagquery serialization, or backend/API behavior.Please update
tests/unit/hooks/useAdvancedSearchFilters.test.tsso the current empty-tag-list case expects Tag to be hidden. Also cover:What alternative solutions did you explore? (Optional)
I considered removing
No tagfrom the Tag picker when there are no real tags, but that would only hide the symptom after the bad filter row is already visible. The correct fix is to prevent the Tag filter row from being shown when there are no real tag values to filter by.melvin-bot commentedon Jun 15, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @DylanDylann (
External)ahmdshrif commentedon Jun 15, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
[-]Spend - Tag filter is present when account has no tag[/-][+][$250] Spend - Tag filter is present when account has no tag[/+]melvin-bot commentedon Jun 15, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022066458272251739905
64 remaining items
melvin-bot commentedon Jun 28, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Jun 28, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
DylanDylann commentedon Jul 1, 2026
@mallenexpensify Please reassign this issue to @daledah
melvin-bot commentedon Jul 1, 2026
@mallenexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!
mallenexpensify commentedon Jul 2, 2026
Payment Summary
Contributor+: @daledah due $250 via NewDot
quinthar commentedon Aug 19, 2026
Approved $250 to @daledah