Skip to content

Move multi-level tag Required from the Tags table to Rules - #98414

Open
Krishna2323 wants to merge 11 commits into
Expensify:mainfrom
Krishna2323:krishna2323/issue-95764-multilevel-tag-required
Open

Move multi-level tag Required from the Tags table to Rules#98414
Krishna2323 wants to merge 11 commits into
Expensify:mainfrom
Krishna2323:krishna2323/issue-95764-multilevel-tag-required

Conversation

@Krishna2323

Copy link
Copy Markdown
Contributor

Explanation of Change

Fixed Issues

$ #95764
PROPOSAL:

Tests

Testing steps

Per-level Required — independent multi-level tags

  1. On Control with rulesRevamp enabled, create two independent tag lists (e.g. State, Region), each with enabled tags.
  2. Go to Rules → General → Require fields for all expenses.
  3. Verify one toggle per tag list, labelled by its name, plus Category.
  4. Enable State, leave Region off, and save.
  5. Reopen and verify State is on, Region is off, and the General row lists the required fields correctly.

Single/dependent tags

  1. With one tag list (e.g. Department), verify one Department toggle and matching General row description.
  2. With dependent tag lists, verify one Tag toggle and Tag in the General row.

Disabled tag levels

  1. Disable all tags in Region and verify its Required toggle is disabled while State remains interactive.
  2. If Region is already required, verify its toggle remains interactive so it can be turned off.

Tags load without visiting Tags

  1. After a fresh login/hard refresh, go directly to Rules → General → Require fields and verify per-level tag rows load correctly.

Required removed from Tags table (beta on)

  1. Verify the Required column, row switches, bulk Require/Make optional actions, and detail-page toggle are gone.
  2. Verify Delete selection still works.

Beta off

  1. Disable rulesRevamp and verify all existing Required controls/actions return and work, including the warning when making the last required tag list optional.
  • Verify that no errors appear in the JS console

Offline tests

  • Same as tests

QA Steps

  • Same as tests

  • 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
    • MacOS: Desktop
  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@Krishna2323
Krishna2323 marked this pull request as ready for review August 12, 2026 11:02
@Krishna2323
Krishna2323 requested review from a team as code owners August 12, 2026 11:02
@melvin-bot

melvin-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

@situchan Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot removed request for a team August 12, 2026 11:02
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@Krishna2323

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/components/Tables/WorkspaceTagsTable/index.tsx 69.81% <100.00%> (+0.58%) ⬆️
src/pages/workspace/tags/WorkspaceTagsPage.tsx 48.88% <66.66%> (-0.14%) ⬇️
...es/workspace/tags/DynamicWorkspaceViewTagsPage.tsx 0.00% <0.00%> (ø)
...c/pages/workspace/rules/RulesRequireFieldsPage.tsx 69.91% <65.71%> (+2.54%) ⬆️
...pace/rules/IndividualExpenseRulesSectionRevamp.tsx 2.06% <0.00%> (-0.30%) ⬇️
... and 289 files with indirect coverage changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 62ceef335c

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/pages/workspace/rules/RulesRequireFieldsPage.tsx Outdated
Comment thread src/pages/workspace/rules/RulesRequireFieldsPage.tsx
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@MelvinBot

Copy link
Copy Markdown
Contributor

Reviewed the changes. The overall approach is clean — gating the old Required column/switches/bulk-actions behind rulesRevamp and moving per-level Required into the Rules page reads well, and the tests track the new behavior. Two things stood out: one likely bug, one behavior question.

🐛 Per-level toggles render stale (all-off) after a delayed tag load

This is exactly testing step 10 (fresh login / hard refresh → go straight to Rules → General → Require fields).

The sync effect is one-shot per policy.id, but tagRequiredByLevel is derived from policyTags, which loads asynchronously via openPolicyTagsPage — a plain API.read with no optimistic data (Tag.ts:71-82). On a hard refresh the policy object usually resolves before the tags arrive, and then:

  1. The effect runs while initialTagRequiredByLevel is still {}, sets syncedPolicyIDRef.current = policy.id, and stores {}.
  2. Tags land, initialTagRequiredByLevel recomputes to the real per-level values, the effect re-fires — but the syncedPolicyIDRef.current === policy.id guard now early-returns.
  3. The real values never reach state, so every level renders OFF even when required (RulesRequireFieldsPage.tsx:285).

policy.isLoading only tracks the policy object, not the tags, so nothing re-syncs once the tags arrive (sync effect L84-L93). The tests don't catch it because setupPolicy seeds policyTags before render.

Suggested fix: sync tagRequiredByLevel in its own effect that re-applies when policyTags populates (or drop it from the policy.id-guarded effect), so it isn't committed before the tags exist.

❓ "Can't make all tag lists optional" guard is dropped for independent multi-level tags

On the old Tags table, toggling off the last required list is hard-blocked with the cannotMakeAllTagsOptional warning (WorkspaceTagsPage.tsx:302-305). The new per-level toggles have no equivalent — with rulesRevamp on, a user can turn every level optional and Save. Testing step 13 verifies that warning for beta-off, but there's no beta-on counterpart. Is dropping that protection intentional for the revamp, or should it be carried over to the per-level toggles?


Nothing else blocking from my read. Happy to implement either fix — reply with @MelvinBot implement ... if you'd like me to.

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
…s section

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚧 JmillsExpensify has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

Copy link
Copy Markdown
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
Built from App PR #98414.

Android 🤖 iOS 🍎
⏩ SKIPPED ⏩ ⏩ SKIPPED ⏩
The build for Android was skipped The build for iOS was skipped
Web 🕸️
https://98414.pr-testing.expensify.com
Web

👀 View the workflow run that generated this build 👀

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@JmillsExpensify

Copy link
Copy Markdown
Contributor

Tested for a direct integration. Wouldn't these be locked on instead of locked off for this case? We are importing these two accounting lists as tags from NetSuite and they should both be required.

CleanShot 2026-08-12 at 13 54 50@2x CleanShot 2026-08-12 at 13 55 03@2x

@Krishna2323

Copy link
Copy Markdown
Contributor Author

Tested for a direct integration. Wouldn't these be locked on instead of locked off for this case? We are importing these two accounting lists as tags from NetSuite and they should both be required.

@JmillsExpensify could you please share the steps you followed? Did you use the Sage Intacct C+ Contributor+ account?

@trjExpensify

Copy link
Copy Markdown
Contributor

Not sure on the steps, but it's a workspace connected to NetSuite I added him to owned by tom+integrationsmaster@trj.chat

  1. tom+integrationsmaster@trj.chat created a workspace and connected to NetSuite
  2. Imported departments as report fields
  3. Imported classes and locations as tags
  4. Invited jason@ to the workspace as an admin

I guess I'm not really following this screen, why would making a tag level required or not be locked? I understand the category one because we force you to minimally categorise expenses.

CleanShot 2026-08-12 at 13 54 50@2x

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@Krishna2323

Copy link
Copy Markdown
Contributor Author

Not sure on the steps, but it's a workspace connected to NetSuite I added him to owned by tom+integrationsmaster@trj.chat

  1. tom+integrationsmaster@trj.chat created a workspace and connected to NetSuite
  2. Imported departments as report fields
  3. Imported classes and locations as tags
  4. Invited jason@ to the workspace as an admin

I guess I'm not really following this screen, why would making a tag level required or not be locked? I understand the category one because we force you to minimally categorise expenses.

@MelvinBot review and also check if there are any behavioral changes.

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@MelvinBot

Copy link
Copy Markdown
Contributor

On the locking question and behavioral changes:

Why the tag Required toggle is locked on a NetSuite workspace

It's locked purely because an accounting connection is active — not because of anything tag-specific. The page gates both the Category and Tag Required toggles on isConnectedToAccounting = hasAccountingConnections(policy):

  • RulesRequireFieldsPage.tsx:53isConnectedToAccounting
  • :56 isCategoryToggleDisabled = … || isConnectedToAccounting
  • :60 isTagToggleDisabled = … || isConnectedToAccounting
  • :136 shouldShowTagLock = isTagFeatureDisabled || isConnectedToAccounting

So the mental model of "category is locked because we force categorization" isn't quite what the code does — both Category and Tag are locked for the same reason: while a connection is active, accounting "owns" these features (mirroring the Categories/Tags toggles on More features). The lock isn't introduced by this PR — it already existed on this page for the single Category/Tag toggles.

Behavioral change this PR does introduce

Yes — for independent multi-level tags (your exact case: NetSuite classes + locations imported as two tag lists), this is a real change:

  • Before (today, in production): the Rules page hid the tag toggle for independent multi-level tags (shouldShowTagToggle on main excluded them), and per-level Required was set from the Tags table, where the switch is gated only by member write-access and the last-required rule — not by the accounting connection (WorkspaceTagsPage.tsx:368, isLocked: !canWriteTags || isMakingLastRequiredTagListOptional(...); canWriteTags is role-based only).
  • After (beta on): per-level Required moves to Rules → Require fields as one toggle per list (:274-296), and those toggles inherit the page's accounting lock.

Net effect: on a NetSuite-connected workspace, the class/location Required toggles are now locked where they were previously editable in the Tags table. That's why the screen looks off to you.

Recommendation

Worth a product decision before merging: is "Required" supposed to be owned by the accounting connection at all? Enabling/disabling tags being accounting-owned makes sense (NetSuite controls which tags exist), but "Required" is an Expensify-side coding rule that admins arguably should still control while connected. If the intent is to keep it editable, the per-level toggles (and the existing single toggle) shouldn't include isConnectedToAccounting in their disabled/lock gate. Also note hasAccountingConnections is true for any connection, so a connection that doesn't even sync tags would still lock these.

I'd confirm the intended behavior with the issue owner / design before adjusting the gate.

@trjExpensify

Copy link
Copy Markdown
Contributor

It's locked purely because an accounting connection is active — not because of anything tag-specific. The page gates both the Category and Tag Required toggles on isConnectedToAccounting = hasAccountingConnections(policy):

@Krishna2323 this doesn't sound right. The isConnectedToAccounting lock was added for Categories because it's a requirement to minimally map an expense to a GL account on export. The only historical restriction is with turning the overall Tags feature off/on as that's driven by the accounting import settings. Whether any of the tag levels are required or not has always been totally optional.

This is an account not on the beta:

2026-08-12_15-18-52.mp4

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.

4 participants