Implementing optimistic category and tag workspace violations #74389
Implementing optimistic category and tag workspace violations #74389cead22 merged 40 commits intoExpensify:mainfrom
Conversation
…gories and tags."" This reverts commit 9f67794.
…lues and adjust transaction count in pushTransactionViolations test
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.
|
… and add eslint directive in tests
…g in usePolicyData
…d IOURequestStepCategory
…ove transaction filtering logic
|
Bump @cead22. |
@situchan On Case 2 on Mac OS the red circle on the LHN doesn't appear while you're offline, and then appears after going online. Is that expected? |
|
@Tony-MK for Test Case 1: Tag Feature, when tags are re-enabled, shouldn't the transaction thread show a tag field? |
I think Case 2 is flaky. #62627 (comment) |
|
Thanks! |
I think it's expected for now (when enable Screen.Recording.2025-11-14.at.3.23.20.AM.mov |
|
@situchan thanks, can you share more details? Why is it expected for now, and why does the reverse case work but not the other one? |
This was reported earlier. And @Tony-MK answered #62627 (comment) and handle as follow-up. Though interesting why we cannot fix this like in-reverse behavior (red circle disappears when transaction thread has no violation) |
I believe so, because all tags stay disabled after the tag feature is re-enabled. In production, that is the case. Sample.mov
It is the |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
| policy: policy as OnyxValueWithOfflineFeedback<Policy>, | ||
| reports: Object.values(reports ?? {}) as Array<OnyxValueWithOfflineFeedback<Report>>, |
There was a problem hiding this comment.
|
🚀 Deployed to staging by https://github.com/cead22 in version: 9.2.59-0 🚀
|
|
This PR is failing because of issue |
|
@Tony-MK Original issue also still reproduced by QA team, PR was failed |
@IuliiaHerets, This will be handled by #75238. |
|
🚀 Deployed to production by https://github.com/grgia in version: 9.2.59-5 🚀
|
| const tagList = policyData.tags?.[tagListName]; | ||
| const tags = tagList.tags ?? {}; |
There was a problem hiding this comment.
There's an edge case of policyData.tags being an empty object after clearing cache and restart.
That led to crash in the next line (tagList.tags 💥 )


Explanation of Change
Created a new hook
usePolicyDatato fetch the policy categories, tags, and reports with their associated transactions and violations.policyDatais used in the functions listed below to make them pure and optimistically show violations when the categories or tags used by expenses have changed./actions/ReportUtils.tspushTransactionViolationsOnyxData()/actions/Policy/Tag.tssetWorkspaceTagEnabled()setWorkspaceTagRequired()deletePolicyTags()enablePolicyTags()renamePolicyTag()setPolicyRequiresTag()setPolicyTagsRequired()/actions/Policy/Category.tsdeleteWorkspaceCategories()enablePolicyCategories()renamePolicyCategory()removePolicyCategoryReceiptsRequired()setPolicyCategoryReceiptsRequired()setWorkspaceCategoryEnabled()setWorkspaceRequiresCategory()Fixed Issues
$ #62698
PROPOSAL:
Tests
Prerequisite for Test Cases 1 - 5: A
Must tag expensesenabled workspaceTest Case 1: Enable and Disable Tag Feature
Missing Tagviolation on the report preview is visible.Missing Tagviolation in the expense thread is visible.Force Offline.Missing Tagviolation on the report preview is not visible.Missing Tagviolation in the expense thread is not visible.Force Offline.Missing Tagviolation on the report preview is not visible.Missing Tagviolation in the expense thread is not visible.Force Offline.Missing Tagviolation on the report preview is not visible.Missing Tagviolation in the expense thread is not visible.Force Offline.Missing Tagviolation on the report preview is not visible.Missing Tagviolation in the expense thread is not visible.Test Case 2: Enable and Disable Tag Requirement
Missing Tagviolation is visible.Force Offline.Must tag expensessetting.Missing Tagviolation is not visible.Force Offline.Force Offline.Must tag expenses.Missing Tagviolation is visible.Force Offline.Test Case 3: Enable and Disable Tag
Force Offline.Tag no longer validviolation is visible.Force Offline.Force Offline.Force Offline.Test Case 4: Delete and Update Expense Tag
Force Offline.Tag no longer validviolation is visible.Force Offline.Force Offline.Force Offline.Test Case 5: Rename Tag
Force Offline.Tag no longer validviolation is visible.Force Offline.Force Offline.Force Offline.Prerequisite for Test Cases 6 - 11: A
Must category expensesenabled workspaceTest Case 6: Enable and Disable Category Feature
Missing Categoryviolation on the report preview is visible.Missing Categoryviolation in the expense thread is visible.Force Offline.Missing Categoryviolation on the report preview is not visible.Missing Categoryviolation in the expense thread is not visible.Force Offline.Missing Categoryviolation on the report preview is not visible.Missing Categoryviolation in the expense thread is not visible.Force Offline.Missing Categoryviolation on the report preview is not visible.Missing Categoryviolation in the expense thread is not visible.Force Offline.Missing Categoryviolation on the report preview is not visible.Missing Categoryviolation in the expense thread is not visible.Test Case 7: Enable and Disable Category Requirement
Missing Categoryviolation is visible.Force Offline.Must category expensessetting.Missing Categoryviolation is not visible.Force Offline.Force Offline.Must category expenses.Missing Categoryviolation is visible.Force Offline.Test Case 8: Enable and Disable Category
Force Offline.Category no longer validviolation is visible.Force Offline.Force Offline.Force Offline.Test Case 9: Delete Category and Update Expense Category
Force Offline.Category no longer validviolation is visible.Force Offline.Force Offline.Force Offline.Test Case 10: Rename Category
Force Offline.Category no longer validviolation is visible.Force Offline.Force Offline.Force Offline.Test Case 11: Set Receipt Required Amount Rule
RulesFeature.Receipt Required Amountwith a random amount value.Receipt Required Amount.Force Offline.Require receipts overto "Always require receipts".Receipt Requiredviolation is visible.Force Offline.Force Offline.Require receipts overto "Never require receipts".Force Offline.Force Offline.Require receipts overto the initial default value.Force Offline.Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand 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
Test Case 1: Tag Feature
Test Case 2: Tag Requirement
Test Case 3: Enable and Disable Tag
Test Case 4: Delete and Update Tag
Android.-.Native.mov
Test Case 5: Rename Tag
Test Case 6: Category Feature
Test Case 7: Category Requirement
Test Case 8: Enable and Disable Category
Test Case 9: Delete and Update Category
Test Case 10: Rename Category
Test Case 11: Set Receipt Required Amount Rule
Android: mWeb Chrome
Test Case 1: Tag Feature
Tag.Feature.webm
Test Case 2: Tag Requirement
Tag.Requirement.webm
Test Case 3: Enable and Disable Tag
Tag.Enable.Disable.webm
Test Case 4: Delete and Update Tag
Tag.Delete.Update.webm
Test Case 5: Rename Tag
Tag.Rename.webm
Test Case 6: Category Feature
Category.Feature.webm
Test Case 7: Category Requirement
Category.Requirement.webm
Test Case 8: Enable and Disable Category
Category.Enable.Disable.webm
Test Case 9: Delete and Update Category
Category.Delete.Update.webm
Test Case 10: Rename Category
Category.Rename.webm
Test Case 11: Set Receipt Required Amount Rule
Category.Receipt.webm
iOS: Native
Test Case 1: Tag Feature
Tag.Feature.mp4
Test Case 2: Tag Requirement
Tag.Requirement.mp4
Test Case 3: Enable and Disable Tag
Tag.Enable.DIsable.mp4
Test Case 4: Delete and Update Tag
Tag.Delete.Update.mp4
Test Case 5: Rename Tag
Tag.Rename.mp4
Test Case 6: Category Feature
Category.Feature.mp4
Test Case 7: Category Requirement
Category.Requirement.mov
Test Case 8: Enable and Disable Category
Category.Enable.Disable.mp4
Test Case 9: Delete and Update Category
Category.Delete.Update.mp4
Test Case 10: Rename Category
Category.Rename.mp4
Test Case 11: Set Receipt Required Amount Rule
Category.Receipt.mp4
iOS: mWeb Safari
Test Case 1: Tag Feature
Tag.Feature.mp4
Test Case 2: Tag Requirement
Tag.Requirement.mp4
Test Case 3: Enable and Disable Tag
Tag.Enable.Disable.mp4
Test Case 4: Delete and Update Tag
Tag.Delete.Update.mp4
Test Case 5: Rename Tag
Tag.Rename.mp4
Test Case 6: Category Feature
Category.Feature.mp4
Test Case 7: Category Requirement
Category.Requirement.mp4
Test Case 8: Enable and Disable Category
Category.Enable.Disable.mp4
Test Case 9: Delete and Update Category
Category.Delete.Update.mp4
Test Case 10: Rename Category
Category.Rename.mp4
Test Case 11: Set Receipt Required Amount Rule
Category.Receipt.mp4
MacOS: Chrome / Safari
Test Case 1: Tag Feature
Tag.Feature.mov
Test Case 2: Tag Requirement
Enable.Disable.Requirement.mov
Test Case 3: Enable and Disable Tag
Enable.Disable.Tag.mov
Test Case 4: Delete and Update Tag
Tag.Delete.Update.mov
Test Case 5: Tag Rename
Tag.Rename.mov
Test Case 6: Category Feature
Category.Feature.mov
Test Case 7: Category Requirement
Category.Requirement.mov
Test Case 8: Enable and Disable Category
Category.Enable.Disable.mov
Test Case 9: Delete and Update Category
Catergory.Delete.Update.mov
Test Case 10: Rename Category
Category.Rename.mov
Test Case 11: Set Receipt Required Amount Rule
Category.Receipt.mov
MacOS: Desktop
Test Case 1: Tag Feature
Tag.Feature.mov
Test Case 2: Tag Requirement
Tag.Reqirement.mov
Test Case 3: Enable and Disable Tag
Enable.and.Disabled.Tag.mov
Test Case 4: Delete and Update Tag
Delete.and.Update.Tags.mov
Test Case 5: Rename Tag
Rename.Tag.mov
Test Case 6: Category Feature
Catergory.Feature.mov
Test Case 7: Category Requirement
Category.Requirement.mov
Test Case 8: Enable and Disable Category
Category.Enable.Disable.mov
Test Case 9: Delete and Update Category
Category.Delete.and.Update.mov
Test Case 10: Rename Category
Category.Rename.mov
Test Case 11: Set Receipt Required Amount Rule
Category.Receipt.Amount.mov