Fix leading colon in tag value and false tag violations for non-required levels#87198
Conversation
…ionTagsString When transactionTags is an empty string, getTagArrayFromName splits it into [""] (one empty element) instead of []. Setting a tag at index > 0 then produces a leading colon (e.g. ":Alpha" instead of "Alpha"), which triggers false "tag no longer valid" violations. This adds the same empty-string guard already used in IOURequestStepTag.tsx.
The violation check in getTagViolationsForDependentTags blindly flagged
any empty tag level via tags.includes('') and a length mismatch check,
without considering whether each level is actually required. This caused
false ALL_TAG_LEVELS_REQUIRED violations when users only filled some
tag levels that were not required.
Also fill sparse array slots in insertTagIntoTransactionTagsString when
tagIndex exceeds the current array length, preventing undefined entries.
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b15af95663
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
JmillsExpensify
left a comment
There was a problem hiding this comment.
Wild one, glad we caught it. LGTM
|
@wildan-m please merge main |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppios.moviOS: mWeb SafariMacOS: Chrome / Safariweb.mov |
|
Code Review — LGTM with one minor nit Both fixes are correct and well-tested.
Tests cover the key scenarios: empty transactionTags at index > 0, sparse slots, required vs non-required dependent tag levels. Minor nit (non-blocking)The test name at
…expects |
| const tagValue = tags.at(index) ?? ''; | ||
| return tagValue === '' && (policyTagList[key]?.required ?? true); | ||
| }); | ||
| if (hasEmptyRequiredLevel || tags.length > policyTagKeys.length) { |
There was a problem hiding this comment.
Is this condition correct?
tags.length > policyTagKeys.length
Shouldn't this be tags.length < policyTagKeys.length? Actually, this condition is not needed at all.
There was a problem hiding this comment.
situchan is correct — this condition can be removed.
Why < is not needed: hasEmptyRequiredLevel already iterates over all policyTagKeys. When tags.length < policyTagKeys.length, tags.at(index) returns undefined for the missing indices, which coalesces to ''. If those levels are required, hasEmptyRequiredLevel will already be true.
Why > is not needed: Having more tags than policy levels is a stale-data edge case, and flagging it as ALL_TAG_LEVELS_REQUIRED is semantically wrong — that violation means required levels are unfilled, not that there are extra levels. The extra tags are harmless and would be trimmed on next edit.
The hasEmptyRequiredLevel check alone is sufficient.
There was a problem hiding this comment.
You are right, reverted in 59f84f1. Also merged main as requested.
…s than policy" This reverts commit 1e24236.
|
Re-review — LGTM ✅ The code is unchanged since my previous review. All CI checks pass, and
No new concerns. Ready to merge. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f7de5a044
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
🚧 @Julesssss has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/Julesssss in version: 9.3.60-0 🚀
Bundle Size Analysis (Sentry): |
|
No help site changes required. This PR is a bug fix to internal tag validation logic — it corrects two issues:
These are code-level fixes that don't change any user-facing features, workflows, or UI labels. The relevant help articles (Create and Manage Expense Tags, Require Tags and Categories) describe how to set up and require tags — they don't reference the internal tag string format or specific violation behavior that was fixed here. |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.3.60-22 🚀
|
Explanation of Change
When
transactionTagsis an empty string,getTagArrayFromNamesplits it into[""](one empty element) instead of[]. Setting a tag at index > 0 then produces a leading colon (e.g.":Alpha"instead of"Alpha"), which triggers false "tag no longer valid" violations.This fix adds an empty-string guard so that splitting an empty
transactionTagsreturns[]instead of[""], and fills any sparse array slots whentagIndexexceeds the current array length.Additionally,
getTagViolationsForDependentTagsblindly flagged any empty tag level viatags.includes('')and a length mismatch check, without considering whether each level is actually required. This caused falseALL_TAG_LEVELS_REQUIREDviolations when users only filled some tag levels that were not required. The fix now checks each tag level'srequiredproperty before flagging.Fixed Issues
$ #81881
PROPOSAL: #81881 (comment)
Tests
Sample CSV for multi-level tag import (
tags-multilevel.csv):tags-multilevel.csv
Offline tests
The tag validation logic runs locally on cached data, so behavior is unchanged offline.
QA Steps
Same as tests above.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Kapture.2026-04-08.at.06.04.54.mp4
Android: mWeb Chrome
Kapture.2026-04-08.at.06.09.47.mp4
iOS: Native
Kapture.2026-04-08.at.06.22.44.mp4
iOS: mWeb Safari
Kapture.2026-04-08.at.06.25.32.mp4
MacOS: Chrome / Safari
Kapture.2026-04-08.at.05.35.40.mp4