Skip to content

fix: show tag validation error when moving expenses between workspaces#76016

Merged
cristipaval merged 4 commits intoExpensify:mainfrom
marufsharifi:fix/tag-validation-after-expense-move
Jan 8, 2026
Merged

fix: show tag validation error when moving expenses between workspaces#76016
cristipaval merged 4 commits intoExpensify:mainfrom
marufsharifi:fix/tag-validation-after-expense-move

Conversation

@marufsharifi
Copy link
Contributor

@marufsharifi marufsharifi commented Nov 25, 2025

Explanation of Change

Fixed Issues

$ #74589
PROPOSAL: #74589 (Comment)

Tests

Four Scenarios

A. Moving an Expense from a Single-Level Workspace Report to a Multi-Level Workspace Report

  1. Start with an expense in a report under Workspace A, with TagA applied.
  2. Ensure Workspace B uses multi-level tags, where TagA is unavailable (it belongs to a different tag set), and has an empty report.
  3. Switch to offline mode.
  4. Move the expense from Workspace A’s report to a report in Workspace B.
  5. Resolve all required tags across all relevant fields.
  6. Verify that RBR is displayed in the LHN due to a tagOutOfPolicy violation.

B. Moving an Expense from a Multi-Level Workspace Report to a Single-Level Workspace Report

  1. Ensure Workspace A has single-level tags and an empty report.
  2. Start with an expense in Workspace B, which uses multi-level tags, where the tag values do not exist in Workspace A.
  3. Switch to offline mode.
  4. Move the expense from Workspace B’s report to a report in Workspace A.
  5. Verify that a “Tag no longer available” violation error is shown and that RBR appears in the LHN.

C. Moving an Expense from a Single-Level Workspace Report to Another Single-Level Workspace Report

  1. Start with an expense in a report under Workspace A, with TagA applied.
  2. Ensure Workspace B has single-level tags and an empty report, but does not include TagA as an available tag value.
  3. Switch to offline mode.
  4. Move the expense from Workspace A’s report to a report in Workspace B.
  5. Verify that a “Tag no longer available” violation error is displayed and that RBR appears in the LHN.

D. Moving an Expense from a Multi-Level Workspace Report to Another Multi-Level Workspace Report

  1. Ensure Workspace A uses multi-level tags and has an empty report.
  2. Ensure Workspace B also uses multi-level tags, but with a different tag set.
  3. Create an expense in Workspace B.
  4. Switch to offline mode.
  5. Move the expense from Workspace B’s report to a report in Workspace A.
  6. Resolve any required tag violations across all affected fields, if present.
  7. Verify that a “Tag no longer available” violation error is displayed and that RBR appears in the LHN.
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests

QA Steps

Same as Tests

// 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 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
a-n.mp4
Android: mWeb Chrome
Screen.Recording.1404-08-29.at.4.15.07.PM.mov
iOS: Native
Screen.Recording.1404-09-04.at.4.25.53.PM.mp4
iOS: mWeb Safari
Screen.Recording.1404-09-04.at.4.34.40.PM.mov
MacOS: Chrome / Safari
1-web.mp4
2-web.mp4
3-web.mp4
4-web.mp4

@melvin-bot
Copy link

melvin-bot bot commented Nov 25, 2025

@parasharrajat 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 requested review from JmillsExpensify and removed request for a team November 25, 2025 12:33
@codecov
Copy link

codecov bot commented Nov 25, 2025

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/libs/Violations/ViolationsUtils.ts 67.27% <100.00%> (-0.71%) ⬇️
... and 15 files with indirect coverage changes


// Calculate client-side tag violations
const policyRequiresTags = !!policy.requiresTag && !isSelfDM;
const policyRequiresTags = (!!policy.requiresTag || !!updatedTransaction?.tag) && !isSelfDM;
Copy link
Member

Choose a reason for hiding this comment

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

Why are we doing this? What is the impact of this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in offline mode when the target workspace uses a single-level tag, policy.requiresTag is falsy, causing the tag-violation check to be skipped.

that fixed the second issue in this comment

Copy link
Member

Choose a reason for hiding this comment

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

which violation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tag value violation, one of them is tag-out-of-policy.

newTransactionViolations.push({
name: CONST.VIOLATIONS.SOME_TAG_LEVELS_REQUIRED,
type: CONST.VIOLATION_TYPES.VIOLATION,
showInReview: true,
Copy link
Member

Choose a reason for hiding this comment

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

I didn't get how this flag is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we don't set this flag, it won't show the RBR on LHN, on offline mode.

Copy link
Member

Choose a reason for hiding this comment

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

It does not look like the issue talks about showing RBR. If we are making this change, we first need to confirm this and enable it for all violations for all fields which will out of scope of this PR. @cristipaval What do you say?

Copy link
Contributor

Choose a reason for hiding this comment

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

let's test if the RBR shows if we do similar steps to a different field and make it consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cristipaval, I am sure the BE value contains this change, and I proposed it to make FE and BE consistent. Okay, I will test other fields as well, thanks

Copy link
Contributor Author

@marufsharifi marufsharifi Dec 2, 2025

Choose a reason for hiding this comment

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

@parasharrajat, @cristipaval, we already do this for overLimit violation of the amount.

newTransactionViolations.push({
name: shouldCategoryShowOverLimitViolation ? CONST.VIOLATIONS.OVER_CATEGORY_LIMIT : CONST.VIOLATIONS.OVER_LIMIT,
data: {
formattedLimit: CurrencyUtils.convertAmountToDisplayString(shouldCategoryShowOverLimitViolation ? categoryOverLimit : policy.maxExpenseAmount, policy.outputCurrency),
},
type: CONST.VIOLATION_TYPES.VIOLATION,
showInReview: true,
});
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This record demonstrates that the same behavior happens for amount field when target workspace has expense amount limit set.

Screen.Recording.1404-09-11.at.10.05.39.PM.mov

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks! @parasharrajat, this is on you again 🙏

@marufsharifi
Copy link
Contributor Author

@parasharrajat, thank you for the review. I’ve responded to your questions, and please feel free to let me know if you need any additional details.

Copy link
Contributor

@JmillsExpensify JmillsExpensify left a comment

Choose a reason for hiding this comment

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

It should show Tag no longer available violation error

This is correct and approved by product

@marufsharifi
Copy link
Contributor Author

@parasharrajat, could you please continue reviewing here again when you get a chance? Thanks

@marufsharifi
Copy link
Contributor Author

@parasharrajat, friendly bump to continue reviewing. thanks

@parasharrajat
Copy link
Member

Will be testing it today or tomorrow.

@marufsharifi
Copy link
Contributor Author

@parasharrajat, Quick bump. thanks

@parasharrajat
Copy link
Member

Checking...

@marufsharifi
Copy link
Contributor Author

@parasharrajat Quick bump, thanks

@marufsharifi
Copy link
Contributor Author

@parasharrajat kindly bump, thanks

@parasharrajat
Copy link
Member

@marufsharifi Can you please merge main?

@marufsharifi
Copy link
Contributor Author

marufsharifi commented Dec 23, 2025

@marufsharifi Can you please merge main?

@parasharrajat, thanks for the review. Merged the main.

@marufsharifi
Copy link
Contributor Author

@parasharrajat, Quick bump, thanks.

@parasharrajat
Copy link
Member

Thanks for the bump. I will review this soon. If possible, today, but I might not have time to look into this today due to an event.

@marufsharifi
Copy link
Contributor Author

@parasharrajat, kindly bump.

@parasharrajat
Copy link
Member

So I noticed that when the required tag violation is active on any of the multi-level tags, tag out of policy violation does not show up.

04.01.2026_18.03.20_REC.mp4

@parasharrajat
Copy link
Member

@marufsharifi Can you look into ⬆️ issue?

@marufsharifi
Copy link
Contributor Author

@parasharrajat, Thanks for the review. Could you please check this comment? It should be displayed after all the required tags were resolved. first. thanks

@parasharrajat
Copy link
Member

parasharrajat commented Jan 5, 2026

yes, But in this case the department tag field does not have required violation so it should show tag out of policy. How does backend bahave here?

@marufsharifi
Copy link
Contributor Author

@parasharrajat, Okay, I will update the FE, but the BE needs to be updated to work the same as well. thanks

@marufsharifi
Copy link
Contributor Author

yes, But in this case the department tag field does not have required violation so it should show tag out of policy. How does backend bahave here?

@parasharrajat, the BE behaves exactly as you are seeing. here

@parasharrajat
Copy link
Member

Then it's fine.

@marufsharifi
Copy link
Contributor Author

@parasharrajat, thanks. Does this task still need any changes from my side?

@parasharrajat
Copy link
Member

Testing further...

@parasharrajat
Copy link
Member

parasharrajat commented Jan 5, 2026

@marufsharifi I checked that #76016 (comment) was the original issue reported in #74589 (comment)

If that is not changed, then the main issue is not solved. LHN RBR are additional changes.

I see that the current behaviour in this vid is present on staging as well.
image

@parasharrajat
Copy link
Member

So we are fixing multi-level workspace to single level move flow.

@marufsharifi Can you please update test steps to mention different test steps for all flows as you mentioned here #74589 (comment)

@parasharrajat
Copy link
Member

Discussing internally.

@parasharrajat
Copy link
Member

@marufsharifi Can you update the test steps #76016 (comment)?

@marufsharifi
Copy link
Contributor Author

@parasharrajat, thanks for your patience. I have updated the test steps to cover all four scenarios. thanks

@marufsharifi
Copy link
Contributor Author

@parasharrajat, should I create video records for all four senorios in all platforms? thanks

@parasharrajat
Copy link
Member

Go ahead. No harm for me.

@marufsharifi
Copy link
Contributor Author

A. Moving an Expense from a Single-Level Workspace Report to a Multi-Level Workspace Report

s-m.mov

B. Moving an Expense from a Multi-Level Workspace Report to a Single-Level Workspace Report

m-s.mov

C. Moving an Expense from a Single-Level Workspace Report to Another Single-Level Workspace Report

s-s.mov

D. Moving an Expense from a Multi-Level Workspace Report to Another Multi-Level Workspace Report

m-m.mp4

@parasharrajat
Copy link
Member

Thanks for waiting. This is looking good. I will complete the checklist in the morning.

@parasharrajat
Copy link
Member

parasharrajat commented Jan 8, 2026

Screenshots

🔲 iOS / native

08.01.2026_14.54.14_REC.mp4

🔲 iOS / Safari

08.01.2026_14.36.14_REC.mp4

🔲 MacOS / Chrome

08.01.2026_14.20.37_REC.mp4

🔲 Android / Chrome

Facing debugging issues.

🔲 Android / native

08.01.2026_15.47.10_REC.mp4

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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 the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • 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
    • 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 approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • 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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • 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.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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 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 form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label 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.
  • 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

🎀 👀 🎀 C+ reviewed

@melvin-bot melvin-bot bot requested a review from cristipaval January 8, 2026 10:28
@cristipaval cristipaval merged commit 883e8ec into Expensify:main Jan 8, 2026
30 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Jan 8, 2026

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented Jan 8, 2026

🚀 Deployed to staging by https://github.com/cristipaval in version: 9.2.96-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Jan 9, 2026

🚀 Deployed to production by https://github.com/arosiclair in version: 9.2.96-6 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 failure ❌
🍎 iOS 🍎 failure ❌

@OSBotify
Copy link
Contributor

OSBotify commented Jan 9, 2026

🚀 Deployed to production by https://github.com/arosiclair in version: 9.2.96-6 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 failure ❌
🍎 iOS 🍎 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Jan 9, 2026

🚀 Deployed to production by https://github.com/arosiclair in version: 9.2.96-6 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

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.

5 participants