Skip to content

Fix: Multi-level tags show "Required" on all levels when only some are required - #98247

Draft
MelvinBot wants to merge 1 commit into
mainfrom
claude-multiLevelTagRequiredBadge
Draft

Fix: Multi-level tags show "Required" on all levels when only some are required#98247
MelvinBot wants to merge 1 commit into
mainfrom
claude-multiLevelTagRequiredBadge

Conversation

@MelvinBot

Copy link
Copy Markdown
Contributor

Explanation of Change

On a workspace using independent multi-level tags, the create-expense confirmation screen labeled every tag level "Required" whenever the workspace-wide requiresTag flag was on — even levels whose own required flag is false. The badge was purely cosmetic: validation only blocks submission on the levels that are actually required, so the "Required" label disagreed with what the app enforces. Classic Expensify labels only the truly-required level.

The root cause is that the badge and the tag validation used two different rules for multi-level tags:

  • Badge (getTagVisibility in TagsOptionsListUtils.ts) computed isTagRequired = required || !!policy?.requiresTag per tag list. OR-ing in the aggregate policy.requiresTag meant that once it was truthy, every level was labeled "Required" regardless of its own required value.
  • Validation (getTagViolationsForMultiLevelTags in ViolationsUtils.ts) flags a level only when that level's own required is set (policyTagList[key].required ?? true), so only the truly-required level blocks submission.

This change makes the badge mirror the per-level validation for multi-level tags: for multi-level policies isTagRequired is now required ?? true (the same rule validation uses), while single-level policies keep the existing required || !!policy?.requiresTag behavior (their per-list required may be unset, so policy.requiresTag is what makes the single level required). Added a unit test covering an independent three-level policy where only the first level is required.

Fixed Issues

$ #98232
PROPOSAL: #98232 (comment)

Tests

// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review". Please describe what tests you performed that validate your change worked.

Suggested steps:

  1. Use a workspace with independent (not dependent) multi-level tags — three levels A, B, C — with only Level A set to Required and the workspace requiring tags.
  2. Start creating a new expense on that workspace and open the confirmation screen where the tag fields are listed.
  3. Verify only Level A shows the "Required" label; Levels B and C show no label.
  4. Verify submission is still blocked only when Level A is empty (B and C can be left blank).
  5. Regression: a single-level required-tag workspace still shows "Required" on its one level.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

Co-authored-by: huult <huult@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

The failing build check is unrelated to this PR — it's an iOS CocoaPods infrastructure error, not something these changes caused. No code fix is needed; the build just needs to be re-run.

Analysis: The build (Expensify Dev, Debug, true) job failed while installing CocoaPods dependencies:

Installing React-Core-prebuilt (0.86.0)
[!] Error installing React-Core-prebuilt
curl: (56) The requested URL returned error: 401
RockError: CocoaPods installation failed.

This is a transient failure fetching the prebuilt React-Core-prebuilt binary from the remote cache (a 401 Unauthorized on the download URL). It happens at the dependency-install step, before any of this PR's code is even compiled.

Evidence it's unrelated: This PR only changes two TypeScript files — src/libs/TagsOptionsListUtils.ts and tests/unit/TagsOptionsListUtilsTest.ts. It touches no iOS/native code, no Podfile, and no dependency versions, so it can't affect CocoaPods binary downloads.

The other two red checks are the standard PR Reviewer Checklist / checklist and Check independent approval gates, which are process/approval checks, not code failures. All code checks that have completed are green (ESLint, TypeScript check, Oxfmt, React Compiler, Bun tests, one of the Jest shards already passed, etc.).

Recommendation: Re-run the failed iOS build job — this class of 401 on the prebuilt-pod fetch is a known transient infra issue and typically clears on retry. I'm not pushing a code change since there's nothing in this PR to fix.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No new failure here — the situation is unchanged from my previous comment, and the picture is now even clearer.

Since then, all the code checks that were pending have completed and passed: all 8 test (Jest) shards, typecheck, Bun tests, and Storybook tests are green. The PR's own new unit test in tests/unit/TagsOptionsListUtilsTest.ts runs as part of those shards and passes.

The only red check that's an actual failure is still build (Expensify Dev, Debug, true) — the same iOS CocoaPods infrastructure error (curl: (56) ... error: 401 fetching the prebuilt React-Core-prebuilt binary). It has not been re-run since. This is unrelated to this PR's TypeScript-only changes; there is nothing in the code to fix.

Recommendation: Re-run the failed iOS build job. The remaining two red marks (checklist and Check independent approval) are process/approval gates, not code failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants