Skip to content

Filter DELETE-pending transactions out of LHN RBR aggregation - #97706

Open
dilshodmackbook-sketch wants to merge 1 commit into
Expensify:mainfrom
dilshodmackbook-sketch:fix/96967-rbr-reverted-split
Open

Filter DELETE-pending transactions out of LHN RBR aggregation#97706
dilshodmackbook-sketch wants to merge 1 commit into
Expensify:mainfrom
dilshodmackbook-sketch:fix/96967-rbr-reverted-split

Conversation

@dilshodmackbook-sketch

@dilshodmackbook-sketch dilshodmackbook-sketch commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Reverting a split on a report removes the split child transaction(s) optimistically — they are marked with pendingAction: DELETE and stay in Onyx (with their reportID and their transactionViolations entry) until the server confirms and nulls them.

The LHN red-dot (RBR) is computed by getViolatingReportIDForRBRInLHN in src/libs/ReportUtils.ts. It built the report's transaction set with a plain getReportTransactions(...) and did not exclude transactions that are pending deletion. That set is passed down into hasVisibleViolationsForUser / hasViolations / hasWarningTypeViolations / hasNoticeTypeViolationsForRBRInLHN, each of which reads transactionViolations_<transactionID> for every transaction — so a DELETE-pending transaction whose violation entry still existed kept the red dot lit.

Meanwhile the report contents (and the sibling "is this report empty" check a few lines above in the same file) already filter out DELETE-pending transactions, which is why the opened report looked clean. The LHN aggregation and the report view disagreed about whether the reverted transaction still existed.

This PR makes the RBR aggregation ignore transactions that are already pending deletion, mirroring the empty-report check in the same function:

const transactions = getReportTransactions(potentialReport.reportID).filter((transaction) => transaction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);

Because this filtered array is the one handed to every downstream violation check, the single change fixes the whole RBR path in one place and keeps the LHN consistent with what the opened report actually renders — for reverted splits and any other flow that leaves a transaction queued for deletion.

A unit test was added to tests/unit/ReportUtilsTest.ts covering the case where the only violating transaction is DELETE-pending, asserting getViolatingReportIDForRBRInLHN returns null.

Fixed Issues

$ #96967
PROPOSAL: #96967 (comment)

Tests

  1. Open a report and move some expenses onto it.
  2. Split an expense on the report.
  3. Revert the split.
  4. Open the report and observe there are no per-transaction violations to fix.
  5. Verify the report's RBR (red-dot) indicator in the LHN is not shown while the reverted split's child transaction is still queued for deletion.
  6. Verify reports that genuinely have violations still show the RBR indicator.
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline.
  2. Split an expense on a report, then revert the split.
  3. Verify the LHN does not show a policy-violation red-dot for that report while the reverted child transaction sits pending deletion.
  4. Go back online and verify the state stays consistent after the server confirms the removal.

QA Steps

  1. Open a report and move some expenses onto it.
  2. Split an expense on the report.
  3. Revert the split.
  4. Open the report and confirm there are no per-transaction violations to fix.
  5. Verify the report no longer shows a policy-violation red-dot (RBR) indicator in the LHN.
  6. Verify reports that do have real violations still display the RBR indicator.
  • 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 followed proper code patterns (see Reviewing the code)
    • 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 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)
  • 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)
  • 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.
  • 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
96967-android.mp4
Android: mWeb Chrome
video_2026-08-04_00-12-57.mp4
iOS: Native
96967-ios.mp4
iOS: mWeb Safari
video_2026-08-04_00-12-59.mp4
MacOS: Chrome / Safari
96967-macos-chrome.online-video-cutter.com.mp4

Reverting a split leaves the split child transaction in Onyx marked
pendingAction DELETE until the server confirms. getViolatingReportIDForRBRInLHN
counted that lingering transaction's violation and kept the report's red-dot
lit, while the opened report (which filters DELETE-pending transactions) looked
clean. Filter DELETE-pending transactions from the RBR aggregation, mirroring
the empty-report check in the same file.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dilshodmackbook-sketch

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 3efef0859f

ℹ️ 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".

@dilshodmackbook-sketch
dilshodmackbook-sketch marked this pull request as ready for review August 3, 2026 20:18
@dilshodmackbook-sketch
dilshodmackbook-sketch requested review from a team as code owners August 3, 2026 20:18
@melvin-bot
melvin-bot Bot requested a review from marufsharifi August 3, 2026 20:18
@melvin-bot

melvin-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

@marufsharifi 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 garrettmknight and removed request for a team August 3, 2026 20:19
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.

1 participant