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
[$175] Tags - The "Tag no longer valid" violation is displayed after deleting the single tag #102931
changed the title [-]Tags - The "Tag no longer valid" violation is displayed after deleting the tag[/-][+]Tags - The "Tag no longer valid" violation is displayed after deleting the single tag[/+]on Oct 3, 2026
Recommended Fix: Don't change the code. Update BrowserStack test case 95492766 so its expected result says: "The 'Tag no longer valid' violation is shown, online and offline." Then close this issue. A product owner should confirm, because the deciding discussion isn't public.
I reproduced the behavior on web (dev). After I deleted the only tag, the expense showed "Tag no longer valid":
Commit d6cda4c9a64 in PR 86932 removed the gate and flipped the unit tests to match. The step 3 issue was closed as handled by that PR. The test case was never updated.
Current code path when you delete the only tag
deletePolicyTags recomputes violations for affected expenses (Tag.ts:487-489).
Note: PR 86932's offline test step still says the violation "is not shown". That contradicts the code and the review discussion. It appears to be copied from the original expected result in the step 3 issue, which may be where the stale expectation comes from.
Next Steps: A product owner should confirm the violation is intended. If so, update test case 95492766 and close this issue. Reply with @MelvinBot <your feedback> to refine this analysis.
changed the title [-]Tags - The "Tag no longer valid" violation is displayed after deleting the single tag[/-][+][$175] Tags - The "Tag no longer valid" violation is displayed after deleting the single tag[/+]on Oct 3, 2026
Please re-state the problem that we are trying to solve in this issue.
Create a workspace, add a single tag, create an expense with that tag, then delete the tag. The report preview and expense details show Tag no longer valid. They should not, because there is no other tag left to choose.
What is the root cause of that problem?
Last-tag delete still leaves the old tag string on the expense ("Tag Alpha"). Auto-replace in pushTransactionAutoSelectionsOnyxData only runs when one enabled tag is left (2 → 1). For 1 → 0 it does nothing.
deletePolicyTags then calls pushTransactionViolationsOnyxData. Single-level logic in getTagViolationsForSingleLevelTags (src/libs/Violations/ViolationsUtils.ts) adds tagOutOfPolicy whenever !isTagInPolicy. It no longer checks hasEnabledTagsInList, so an empty tag list still creates the violation.
That is the optimistic path for this bug. The same helper already knows an empty list is not a “pick another tag” case: missingTag is still gated on hasEnabledTagsInList.
There is a second leftover from that split:
getIsViolationFixed for tagOutOfPolicy still returns true when no tags are enabled. Confirmation already treats this as fixed. Preview / details / LHN do not, because they read the Onyx violation that the write path just added.
On the expense itself, shouldShowTagDisabledAlert in MoneyRequestView is the real empty-list UX (delete the stale tag). Showing Tag no longer valid next to that is a dead-end Fix: the picker has nothing valid to select.
So this is not a missing delete handler. It is the write path adding a violation that the “is this fixed?” helper and the disabled-tag alert already treat as not actionable.
What changes do you think we should make in order to solve the problem?
Keep tagOutOfPolicy when other tags are still enabled. Stop adding (and drop leftover) tagOutOfPolicy when the list has zero enabled tags.
That loop already continues when a level has no enabled tags for someTagLevelsRequired. Do the same before pushing tagOutOfPolicy for a stale value on a fully empty level, so last-tag-on-a-level matches single-level.
3. tests/unit/ViolationUtilsTest.ts
Update the two cases that currently require tagOutOfPolicy when every tag is disabled (should add tagOutOfPolicy when transaction has a stale tag and no tags are enabled and the “keep existing” sibling). Empty list → no tagOutOfPolicy. Leave tests where another tag in the list is still enabled.
No change needed in deletePolicyTags itself. It already recomputes through pushTransactionViolationsOnyxData; fixing the helper fixes the optimistic preview.
Deleting one tag while others remain still shows Tag no longer valid, which is correct.
What alternative solutions did you explore? (Optional)
Clear transaction.tag on 1 → 0 inside pushTransactionAutoSelectionsOnyxData. Possible follow-up, but the backend can still send the old tag + violation. The helper change is the smaller, local fix.
Hide it only in the UI (hasViolation / useViolations). The blocking violation would still sit in Onyx.
Please re-state the problem that we are trying to solve in this issue.
When a workspace has a single tag and an expense is created using that tag, deleting the tag from Workspace Settings > Tags results in a persistent "Tag no longer valid" (tagOutOfPolicy) violation on the expense in the report preview, expense details, and LHN.
Because that tag was the only tag in the workspace and zero enabled tags remain, the user cannot select any valid tag to resolve the violation. The expected behavior is that no "Tag no longer valid" violation should be displayed once zero enabled tags remain in the workspace.
What is the root cause of that problem?
Unconditional addition & retention of tagOutOfPolicy in getTagViolationsForSingleLevelTags:
In src/libs/Violations/ViolationsUtils.ts (lines 104–115):
// Add 'tagOutOfPolicy' if the tag is not in policy. Not gated on enabled tags remaining, so deleting the// last tag still flags a transaction that holds the deleted tag. Mirrors 'categoryOutOfPolicy'.if(!hasTagOutOfPolicyViolation&&updatedTransaction.tag&&!isTagInPolicy){consttagName=policyTagList[policyTagListName]?.name;consttagNameToShow=isDefaultTagName(tagName) ? undefined : tagName;newTransactionViolations.push({name: CONST.VIOLATIONS.TAG_OUT_OF_POLICY,type: CONST.VIOLATION_TYPES.VIOLATION,data: {tagName: tagNameToShow},showInReview: true});}// Remove 'tagOutOfPolicy' violation if tag is empty or in policyif(hasTagOutOfPolicyViolation&&(!updatedTransaction.tag||isTagInPolicy)){newTransactionViolations=reject(newTransactionViolations,{name: CONST.VIOLATIONS.TAG_OUT_OF_POLICY});}
When the single tag is deleted, hasEnabledTagsInList is false. However, line 106 deliberately did not gate on hasEnabledTagsInList based on the old assumption of mirroring categoryOutOfPolicy. Furthermore, line 113 does not reject tagOutOfPolicy when !hasEnabledTagsInList.
Direct contradiction with getIsViolationFixed:
In src/libs/Violations/ViolationsUtils.ts (lines 344–357), getIsViolationFixed contains the definitive resolution check:
When zero enabled tags remain across the policy (!hasAnyEnabledTags), getIsViolationFixedalready returns true (treating tagOutOfPolicy as resolved). However, because the write path in getTagViolationsForSingleLevelTags persists the violation into Onyx unconditionally, the report preview, LHN, and RBR count continue to display the stale violation.
Mismatch with MoneyRequestView's shouldShowTagDisabledAlert:
In src/components/ReportActionItem/MoneyRequestView.tsx (lines 546 and 1221–1224):
When zero enabled tags remain in the workspace, clicking the tag row already triggers showTagDisabledAlert to prompt the user to remove the stale tag (since the picker cannot be opened). Flagging tagOutOfPolicy next to this creates an unfixable dead-end for the user.
What changes do you think we should make in order to solve the problem?
1. Update src/libs/Violations/ViolationsUtils.ts
In getTagViolationsForSingleLevelTags (lines 104–115):
Add hasEnabledTagsInList to the condition for adding tagOutOfPolicy.
Add !hasEnabledTagsInList to the condition for removing tagOutOfPolicy.
// Add 'tagOutOfPolicy' if the tag is not in policy and there are enabled tags remaining in policyif(!hasTagOutOfPolicyViolation&&updatedTransaction.tag&&!isTagInPolicy&&hasEnabledTagsInList){consttagName=policyTagList[policyTagListName]?.name;consttagNameToShow=isDefaultTagName(tagName) ? undefined : tagName;newTransactionViolations.push({name: CONST.VIOLATIONS.TAG_OUT_OF_POLICY,type: CONST.VIOLATION_TYPES.VIOLATION,data: {tagName: tagNameToShow},showInReview: true});}// Remove 'tagOutOfPolicy' violation if tag is empty, in policy, or there are no enabled tags remainingif(hasTagOutOfPolicyViolation&&(!updatedTransaction.tag||isTagInPolicy||!hasEnabledTagsInList)){newTransactionViolations=reject(newTransactionViolations,{name: CONST.VIOLATIONS.TAG_OUT_OF_POLICY});}
2. Update tests/unit/ViolationUtilsTest.ts
Update the unit tests at lines 2083–2141 that previously required tagOutOfPolicy when zero tags are enabled:
should add tagOutOfPolicy when transaction has a stale tag and no tags are enabled: Update name to should not add tagOutOfPolicy when transaction has a stale tag and no tags are enabled and assert:
should keep existing tagOutOfPolicy when transaction has a stale tag and no tags are enabled: Update name to should remove existing tagOutOfPolicy when transaction has a stale tag and no tags are enabled and assert:
Add a test verifying single-tag deletion (workspace with 1 tag, expense tagged with it, tag deleted resulting in empty tags list {}) confirms zero violations returned.
Tests where other tags in the list remain enabled (e.g. line 2022 and getIsViolationFixed line 4621) remain unchanged and ensure tagOutOfPolicy continues to be added when other valid tags exist.
What alternative solutions did you explore? (Optional)
Clearing transaction.tag in pushTransactionAutoSelectionsOnyxData when transitioning from 1 → 0 tags: pushTransactionAutoSelectionsOnyxData is designed for auto-selecting an alternative valid option (2 → 1). Erasing the transaction tag string directly would cause client/backend divergence because the backend retains historical transaction tag strings. It also breaks MoneyRequestView's intended shouldShowTagDisabledAlert flow, which lets users see the previous tag and explicitly confirm removal.
UI-only suppression (hasVisibleViolationsForUser / useViolations):
Hiding it only in the UI leaves the raw tagOutOfPolicy violation in Onyx, causing issues for export validations, external reports, and raw violation counters. Fixing it in ViolationsUtils.ts ensures complete consistency across Onyx and the UI.
📣 @garvijunagadh! 📣
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>
Please re-state the problem that we are trying to solve in this issue.
In a workspace with a single tag (e.g. "Tag Alpha"), after creating an expense with that tag and subsequently deleting "Tag Alpha" from Workspace Settings > Tags, the expense displays a persistent "Tag no longer valid" (tagOutOfPolicy) violation on the report preview and transaction view. Because 0 enabled tags remain in the workspace, tapping the Tag row blocks the user from opening the tag picker, leaving them trapped in an unresolvable violation state.
And verified by the unit test at tests/unit/ViolationUtilsTest.ts:4612: it('should return true when tag exists but no tags are enabled')
When a policy has zero enabled tags remaining, getIsViolationFixed authoritatively returns true (meaning tagOutOfPolicy is satisfied and should not block the user).
getTagViolationsForSingleLevelTags violates this contract:
In src/libs/Violations/ViolationsUtils.ts:100-115:
constisTagInPolicy=policyTags ? !!policyTags[updatedTransaction.tag??'']?.enabled : false;consthasEnabledTagsInList=hasEnabledTags(policyTags);letnewTransactionViolations=[...transactionViolations];// Add 'tagOutOfPolicy' if the tag is not in policy. Not gated on enabled tags remaining, so deleting the// last tag still flags a transaction that holds the deleted tag. Mirrors 'categoryOutOfPolicy'.if(!hasTagOutOfPolicyViolation&&updatedTransaction.tag&&!isTagInPolicy){
...
newTransactionViolations.push({name: CONST.VIOLATIONS.TAG_OUT_OF_POLICY, ...});}// Remove 'tagOutOfPolicy' violation if tag is empty or in policyif(hasTagOutOfPolicyViolation&&(!updatedTransaction.tag||isTagInPolicy)){newTransactionViolations=reject(newTransactionViolations,{name: CONST.VIOLATIONS.TAG_OUT_OF_POLICY});}
Notice that while hasEnabledTagsInList is computed at line 101, it was only applied to missingTag. For tagOutOfPolicy:
It unconditionally pushes tagOutOfPolicy when !isTagInPolicy, even when zero enabled tags exist in the policy (!hasEnabledTagsInList).
It fails to reject/clear tagOutOfPolicy when the last remaining tag is deleted or disabled (!hasEnabledTagsInList).
In getTagViolationForIndependentTags (multi-level tags):
Lines 213–228 push tagOutOfPolicy for a selected tag level without checking hasEnabledTags(tags) for that level, causing the same deadlock on multi-level tag setups when a whole tag list is emptied.
What changes do you think we should make in order to solve the problem?
1. Update getTagViolationsForSingleLevelTags in src/libs/Violations/ViolationsUtils.ts
Gate the addition of tagOutOfPolicy on hasEnabledTagsInList, and clear existing tagOutOfPolicy violations when zero enabled tags remain in the list:
// Add 'tagOutOfPolicy' if the tag is not in policy and there are still enabled tags in the policyif(!hasTagOutOfPolicyViolation&&updatedTransaction.tag&&!isTagInPolicy&&hasEnabledTagsInList){consttagName=policyTagList[policyTagListName]?.name;consttagNameToShow=isDefaultTagName(tagName) ? undefined : tagName;newTransactionViolations.push({name: CONST.VIOLATIONS.TAG_OUT_OF_POLICY,type: CONST.VIOLATION_TYPES.VIOLATION,data: {tagName: tagNameToShow},showInReview: true});}// Remove 'tagOutOfPolicy' violation if tag is empty, in policy, or if no enabled tags remain in the policyif(hasTagOutOfPolicyViolation&&(!updatedTransaction.tag||isTagInPolicy||!hasEnabledTagsInList)){newTransactionViolations=reject(newTransactionViolations,{name: CONST.VIOLATIONS.TAG_OUT_OF_POLICY});}
2. Update getTagViolationForIndependentTags in src/libs/Violations/ViolationsUtils.ts
In multi-level independent tag evaluations (lines 206–228), ensure tagOutOfPolicy is only added if that tag level contains enabled tags:
3. Update & Add Unit Tests in tests/unit/ViolationUtilsTest.ts
Update existing tests in describe('getTagViolationsForSingleLevelTags') to verify that when hasEnabledTags returns false, tagOutOfPolicy is not added and is cleanly removed if previously present.
Add a new test case verifying that deleting the last active tag in a policy strips the tagOutOfPolicy violation from all existing transactions.
What alternative solutions did you explore? (Optional)
Auto-clearing transaction.tag = '' when deleting the last tag:
Rejected. Deleting workspace policy tags must not mutate historical transaction strings stored in the backend database.
Hiding the violation purely in UI (MoneyRequestView.tsx):
Rejected. Suppressing the error only in presentation leaves stale violation objects in Onyx, corrupting violation counts, RBR badges, LHN error indicators, and export validation. Handling it in ViolationsUtils.ts keeps Onyx data, UI rendering, and getIsViolationFixed in complete 100% harmony.
Activity
applause-bot commentedon Oct 3, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/074b122edeabea7f351c367180713371a4a873cac0b80bc43e6c2fea678377e7
https://platform.applause.com/services/links/v1/external/8f84e7aea25e3bb0469674e00cb7f34f8f41d58a222a66e808d7d200b169daf6
[-]Tags - The "Tag no longer valid" violation is displayed after deleting the tag[/-][+]Tags - The "Tag no longer valid" violation is displayed after deleting the single tag[/+]MelvinBot commentedon Oct 3, 2026
Issue Analysis
Root Cause: This looks like expected behavior. The test case's expected result is out of date. A product decision in June 2026 changed the rule so that deleting the last tag still flags expenses that use it. auto select some values of transaction after deletion one of last 2 elements (
Expensify/App#86932) made that change. It removed the "no enabled tags" check inViolationsUtils.ts:104-115.Recommended Fix: Don't change the code. Update BrowserStack test case 95492766 so its expected result says: "The 'Tag no longer valid' violation is shown, online and offline." Then close this issue. A product owner should confirm, because the deciding discussion isn't public.
I reproduced the behavior on web (dev). After I deleted the only tag, the expense showed "Tag no longer valid":
Investigation details
History of this rule
lakchoterelayed the product answer: if the last tag is deleted, an expense that still holds it should showtagOutOfPolicy.d6cda4c9a64in PR 86932 removed the gate and flipped the unit tests to match. The step 3 issue was closed as handled by that PR. The test case was never updated.Current code path when you delete the only tag
deletePolicyTagsrecomputes violations for affected expenses (Tag.ts:487-489).ViolationsUtils.ts:562-566).ViolationsUtils.ts:104-110).ViolationUtilsTest.ts:2083).Note: PR 86932's offline test step still says the violation "is not shown". That contradicts the code and the review discussion. It appears to be copied from the original expected result in the step 3 issue, which may be where the stale expectation comes from.
Next Steps: A product owner should confirm the violation is intended. If so, update test case 95492766 and close this issue. Reply with
@MelvinBot <your feedback>to refine this analysis.melvin-bot commentedon Oct 3, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @linhvovan29546 (
External)[-]Tags - The "Tag no longer valid" violation is displayed after deleting the single tag[/-][+][$175] Tags - The "Tag no longer valid" violation is displayed after deleting the single tag[/+]melvin-bot commentedon Oct 3, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022106349452023726528
Pintu-Jha commentedon Oct 3, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
Create a workspace, add a single tag, create an expense with that tag, then delete the tag. The report preview and expense details show Tag no longer valid. They should not, because there is no other tag left to choose.
What is the root cause of that problem?
Last-tag delete still leaves the old tag string on the expense (
"Tag Alpha"). Auto-replace inpushTransactionAutoSelectionsOnyxDataonly runs when one enabled tag is left (2 → 1). For 1 → 0 it does nothing.deletePolicyTagsthen callspushTransactionViolationsOnyxData. Single-level logic ingetTagViolationsForSingleLevelTags(src/libs/Violations/ViolationsUtils.ts) addstagOutOfPolicywhenever!isTagInPolicy. It no longer checkshasEnabledTagsInList, so an empty tag list still creates the violation.That is the optimistic path for this bug. The same helper already knows an empty list is not a “pick another tag” case:
missingTagis still gated onhasEnabledTagsInList.There is a second leftover from that split:
getIsViolationFixedfortagOutOfPolicystill returnstruewhen no tags are enabled. Confirmation already treats this as fixed. Preview / details / LHN do not, because they read the Onyx violation that the write path just added.On the expense itself,
shouldShowTagDisabledAlertinMoneyRequestViewis the real empty-list UX (delete the stale tag). Showing Tag no longer valid next to that is a dead-end Fix: the picker has nothing valid to select.So this is not a missing delete handler. It is the write path adding a violation that the “is this fixed?” helper and the disabled-tag alert already treat as not actionable.
What changes do you think we should make in order to solve the problem?
Keep
tagOutOfPolicywhen other tags are still enabled. Stop adding (and drop leftover)tagOutOfPolicywhen the list has zero enabled tags.1.
src/libs/Violations/ViolationsUtils.ts—getTagViolationsForSingleLevelTagshasEnabledTagsInListis already computed. Use it on add and on remove:2. Same file —
getTagViolationForIndependentTagsThat loop already
continues when a level has no enabled tags forsomeTagLevelsRequired. Do the same before pushingtagOutOfPolicyfor a stale value on a fully empty level, so last-tag-on-a-level matches single-level.3.
tests/unit/ViolationUtilsTest.tsUpdate the two cases that currently require
tagOutOfPolicywhen every tag is disabled (should add tagOutOfPolicy when transaction has a stale tag and no tags are enabledand the “keep existing” sibling). Empty list → notagOutOfPolicy. Leave tests where another tag in the list is still enabled.No change needed in
deletePolicyTagsitself. It already recomputes throughpushTransactionViolationsOnyxData; fixing the helper fixes the optimistic preview.Deleting one tag while others remain still shows Tag no longer valid, which is correct.
What alternative solutions did you explore? (Optional)
getIsViolationFixedvstagDisabledAlertout of sync, which is what this Daily is hitting.transaction.tagon 1 → 0 insidepushTransactionAutoSelectionsOnyxData. Possible follow-up, but the backend can still send the old tag + violation. The helper change is the smaller, local fix.hasViolation/useViolations). The blocking violation would still sit in Onyx.substeemguy commentedon Oct 3, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a workspace has a single tag and an expense is created using that tag, deleting the tag from Workspace Settings > Tags results in a persistent "Tag no longer valid" (
tagOutOfPolicy) violation on the expense in the report preview, expense details, and LHN.Because that tag was the only tag in the workspace and zero enabled tags remain, the user cannot select any valid tag to resolve the violation. The expected behavior is that no "Tag no longer valid" violation should be displayed once zero enabled tags remain in the workspace.
What is the root cause of that problem?
Unconditional addition & retention of
tagOutOfPolicyingetTagViolationsForSingleLevelTags:In
src/libs/Violations/ViolationsUtils.ts(lines 104–115):When the single tag is deleted,
hasEnabledTagsInListisfalse. However, line 106 deliberately did not gate onhasEnabledTagsInListbased on the old assumption of mirroringcategoryOutOfPolicy. Furthermore, line 113 does not rejecttagOutOfPolicywhen!hasEnabledTagsInList.Direct contradiction with
getIsViolationFixed:In
src/libs/Violations/ViolationsUtils.ts(lines 344–357),getIsViolationFixedcontains the definitive resolution check:When zero enabled tags remain across the policy (
!hasAnyEnabledTags),getIsViolationFixedalready returnstrue(treatingtagOutOfPolicyas resolved). However, because the write path ingetTagViolationsForSingleLevelTagspersists the violation into Onyx unconditionally, the report preview, LHN, and RBR count continue to display the stale violation.Mismatch with
MoneyRequestView'sshouldShowTagDisabledAlert:In
src/components/ReportActionItem/MoneyRequestView.tsx(lines 546 and 1221–1224):When zero enabled tags remain in the workspace, clicking the tag row already triggers
showTagDisabledAlertto prompt the user to remove the stale tag (since the picker cannot be opened). FlaggingtagOutOfPolicynext to this creates an unfixable dead-end for the user.What changes do you think we should make in order to solve the problem?
1. Update
src/libs/Violations/ViolationsUtils.tsIn
getTagViolationsForSingleLevelTags(lines 104–115):hasEnabledTagsInListto the condition for addingtagOutOfPolicy.!hasEnabledTagsInListto the condition for removingtagOutOfPolicy.2. Update
tests/unit/ViolationUtilsTest.tsUpdate the unit tests at lines 2083–2141 that previously required
tagOutOfPolicywhen zero tags are enabled:should add tagOutOfPolicy when transaction has a stale tag and no tags are enabled: Update name toshould not add tagOutOfPolicy when transaction has a stale tag and no tags are enabledand assert:should keep existing tagOutOfPolicy when transaction has a stale tag and no tags are enabled: Update name toshould remove existing tagOutOfPolicy when transaction has a stale tag and no tags are enabledand assert:{}) confirms zero violations returned.Tests where other tags in the list remain enabled (e.g. line 2022 and
getIsViolationFixedline 4621) remain unchanged and ensuretagOutOfPolicycontinues to be added when other valid tags exist.What alternative solutions did you explore? (Optional)
Clearing
transaction.taginpushTransactionAutoSelectionsOnyxDatawhen transitioning from 1 → 0 tags:pushTransactionAutoSelectionsOnyxDatais designed for auto-selecting an alternative valid option (2 → 1). Erasing the transaction tag string directly would cause client/backend divergence because the backend retains historical transaction tag strings. It also breaksMoneyRequestView's intendedshouldShowTagDisabledAlertflow, which lets users see the previous tag and explicitly confirm removal.UI-only suppression (
hasVisibleViolationsForUser/useViolations):Hiding it only in the UI leaves the raw
tagOutOfPolicyviolation in Onyx, causing issues for export validations, external reports, and raw violation counters. Fixing it inViolationsUtils.tsensures complete consistency across Onyx and the UI.melvin-bot commentedon Oct 3, 2026
📣 @garvijunagadh! 📣
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:
substeemguy commentedon Oct 4, 2026
Contributor details
Your Expensify account email: garvijunagadh@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01ff3c252bcc7ad776
melvin-bot commentedon Oct 4, 2026
substeemguy commentedon Oct 4, 2026
Contributor details
Your Expensify account email: garvijunagadh@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01ff3c252bcc7ad776
melvin-bot commentedon Oct 4, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
camesenin commentedon Oct 4, 2026
camesenin commentedon Oct 4, 2026
melvin-bot commentedon Oct 4, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
bonnhatnguyen commentedon Oct 5, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
In a workspace with a single tag (e.g. "Tag Alpha"), after creating an expense with that tag and subsequently deleting "Tag Alpha" from Workspace Settings > Tags, the expense displays a persistent "Tag no longer valid" (
tagOutOfPolicy) violation on the report preview and transaction view. Because 0 enabled tags remain in the workspace, tapping the Tag row blocks the user from opening the tag picker, leaving them trapped in an unresolvable violation state.What is the root cause of that problem?
There is an architectural inconsistency between
getIsViolationFixedandgetTagViolationsForSingleLevelTagsinsrc/libs/Violations/ViolationsUtils.ts:getIsViolationFixedalready defines the expected specification:In
src/libs/Violations/ViolationsUtils.ts:349-352:And verified by the unit test at
tests/unit/ViolationUtilsTest.ts:4612:it('should return true when tag exists but no tags are enabled')When a policy has zero enabled tags remaining,
getIsViolationFixedauthoritatively returnstrue(meaningtagOutOfPolicyis satisfied and should not block the user).getTagViolationsForSingleLevelTagsviolates this contract:In
src/libs/Violations/ViolationsUtils.ts:100-115:Notice that while
hasEnabledTagsInListis computed at line 101, it was only applied tomissingTag. FortagOutOfPolicy:tagOutOfPolicywhen!isTagInPolicy, even when zero enabled tags exist in the policy (!hasEnabledTagsInList).tagOutOfPolicywhen the last remaining tag is deleted or disabled (!hasEnabledTagsInList).In
getTagViolationForIndependentTags(multi-level tags):Lines 213–228 push
tagOutOfPolicyfor a selected tag level without checkinghasEnabledTags(tags)for that level, causing the same deadlock on multi-level tag setups when a whole tag list is emptied.What changes do you think we should make in order to solve the problem?
1. Update
getTagViolationsForSingleLevelTagsinsrc/libs/Violations/ViolationsUtils.tsGate the addition of
tagOutOfPolicyonhasEnabledTagsInList, and clear existingtagOutOfPolicyviolations when zero enabled tags remain in the list:2. Update
getTagViolationForIndependentTagsinsrc/libs/Violations/ViolationsUtils.tsIn multi-level independent tag evaluations (lines 206–228), ensure
tagOutOfPolicyis only added if that tag level contains enabled tags:3. Update & Add Unit Tests in
tests/unit/ViolationUtilsTest.tsdescribe('getTagViolationsForSingleLevelTags')to verify that whenhasEnabledTagsreturnsfalse,tagOutOfPolicyis not added and is cleanly removed if previously present.tagOutOfPolicyviolation from all existing transactions.What alternative solutions did you explore? (Optional)
transaction.tag = ''when deleting the last tag:Rejected. Deleting workspace policy tags must not mutate historical transaction strings stored in the backend database.
MoneyRequestView.tsx):Rejected. Suppressing the error only in presentation leaves stale violation objects in Onyx, corrupting violation counts, RBR badges, LHN error indicators, and export validation. Handling it in
ViolationsUtils.tskeeps Onyx data, UI rendering, andgetIsViolationFixedin complete 100% harmony.Contributor details
Your Expensify account email: bonnhatnguyen0@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~0139ed4098bdc50182
melvin-bot commentedon Oct 5, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
linhvovan29546 commentedon Oct 5, 2026
@Expensify/product Could you please confirm whether this issue is expected? If so, please request Applause to update the test case.
Thanks
trjExpensify commentedon Oct 5, 2026
It's expected:
It was rectified in #86932
CC: @m-natarajan
m-natarajan commentedon Oct 5, 2026
Thanks, Updated the test case @trjExpensify
linhvovan29546 commentedon Oct 6, 2026
Close the issue because the test case has been updated.