fix: Offline deleted rules reappear after reconnecting until cache is cleared#85746
fix: Offline deleted rules reappear after reconnecting until cache is cleared#85746nkdengineer wants to merge 2 commits intoExpensify:mainfrom
Conversation
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.
|
|
@sobitneupane 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] |
There was a problem hiding this comment.
💡 Codex Review
App/src/libs/actions/Policy/Category.ts
Lines 118 to 124 in 80c8e0d
When the source workspace has a category queued for deletion, optimisticCategoryMap now skips it, but successCategoryMap and failureCategoryMap still add that key back for every original category. Because these updates use Onyx.METHOD.MERGE, the duplicate workspace recreates the deleted category as a stub entry once the queued duplicate request succeeds or fails, so the category can reappear in the duplicate until the cache is refreshed. Apply the same pendingAction !== DELETE filter to these maps as well.
ℹ️ 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".
| const categoriesCount = Object.values(policyCategories ?? {}).filter((category) => category.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE).length; | ||
| const codingRulesCount = Object.values(policy?.rules?.codingRules ?? {}).filter((rule) => rule.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE).length; |
There was a problem hiding this comment.
Exclude pending-deleted members from the duplicate feature counts
This change filters pending-deleted categories and merchant rules, but the members count in this form still comes from getMemberAccountIDsForWorkspace(policy?.employeeList) with its default includeMemberWithPendingDelete = true. In the offline flow this PR targets, a removed member is still counted in the “Members” row and confirmation modal even though buildDuplicatePolicyData() now drops that member from the duplicated employeeList, so the UI still overstates how many people will be copied.
Useful? React with 👍 / 👎.
Explanation of Change
fix: Offline deleted rules reappear after reconnecting until cache is cleared
Fixed Issues
$ #83130
PROPOSAL: #83130 (comment)
Tests
Offline tests
QA Steps
Same as test
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
Screen.Recording.2026-03-19.at.15.27.02.mov
Android: mWeb Chrome
Screen.Recording.2026-03-19.at.15.25.27.mov
iOS: Native
Screen.Recording.2026-03-19.at.15.23.17.mov
iOS: mWeb Safari
Screen.Recording.2026-03-19.at.15.21.11.mov
MacOS: Chrome / Safari
Screen.Recording.2026-03-19.at.15.18.27.mp4