fix: prevent empty expense report when category is disabled from another tab#92276
fix: prevent empty expense report when category is disabled from another tab#92276nabi-ebrahimi wants to merge 8 commits into
Conversation
|
@Krishna2323 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
Here are some automated review suggestions for this pull request.
Reviewed commit: 18c279a4d9
ℹ️ 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 reportTransactionsAndViolations = currentValue ? {...currentValue} : {}; | ||
| if (!transactions) { | ||
| return {}; | ||
| return reportTransactionsAndViolations; |
There was a problem hiding this comment.
Clear derived transactions when the source collection is gone
When the transaction collection becomes undefined (for example during Onyx.clear() on logout/account reset, or any full collection reset), this now returns the previous derived value instead of {}. Because the derived-value manager passes currentValue from its in-memory cache and then writes the compute result back to Onyx, stale report transactions can be re-persisted after the source collection has been cleared, leaving old expenses visible or even leaking data into the next session. Violation-only updates are already handled later by falling back to previousTransaction, so the no-transactions case should still clear the derived value.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@Krishna2323 I fixed this by returning {} only when there is no violation update. For violation-only updates, we preserve the current derived value so the report transaction is not dropped. Could you please check it ?
|
@Krishna2323 The PR is ready for review. could you please a take a look when you get a chance ? thanks |
OnyxDerived keeps the last computed value in a module-local closure so future source updates can be merged against the previous derived state. When another tab updates the same derived key, the local closure can stay stale even though Onyx has the newer value. Subscribe to the derived key itself so external updates refresh the local snapshot. This prevents later partial source updates from recomputing from stale derived data and accidentally dropping existing report transaction state.
|
@Krishna2323 I also tested tags and taxes. The empty report bug reproduces for categories, tags, and taxes, and this fix resolves it for all three. |
@nabi-ebrahimi could you please share a recording of this bug? |
| sourceValues: undefined, | ||
| }; | ||
|
|
||
| Onyx.connectWithoutView({ |
There was a problem hiding this comment.
Why do we need this? I don't see it being mentioned in the selected proposal.
Explanation of Change
This change prevents an expense report from appearing empty when only the transaction’s violations are refreshed, such as when a category is disabled from another tab. In that case, the transaction data may not be present in the update payload, but the existing expense should still remain visible in the report while its violation state is updated. The fix preserves the last known transaction for violation-only updates, while still allowing real transaction deletes or moves to remove the expense from its previous report as expected.
Fixed Issues
$ #91016
PROPOSAL: #91016 (comment)
Tests
Offline tests
Same as Tests.
QA Steps
Same as Tests.
// TODO: These must be filled out, or the issue title must include "[No QA]."
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-06-02.at.6.16.08.AM.mov
Android: mWeb Chrome
Recording_20260602_061902.mp4
iOS: Native
Screen.Recording.2026-06-02.at.6.42.11.AM.mov
iOS: mWeb Safari
Screen.Recording.2026-06-02.at.7.23.06.AM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-06-02.at.12.35.12.AM.mov