Skip to content

fix: resolve admin "Keep selected" duplicates when transaction thread…#96607

Open
yusufdeveloper2903 wants to merge 1 commit into
Expensify:mainfrom
yusufdeveloper2903:fix/92845-resolve-duplicates-keep-selected
Open

fix: resolve admin "Keep selected" duplicates when transaction thread…#96607
yusufdeveloper2903 wants to merge 1 commit into
Expensify:mainfrom
yusufdeveloper2903:fix/92845-resolve-duplicates-keep-selected

Conversation

@yusufdeveloper2903

Copy link
Copy Markdown
Contributor

Explanation of Change

When an admin resolves duplicate expenses submitted by another member via "Resolve duplicates" → "Keep selected" → "Confirm", the duplicates were not resolved — the DUPLICATED_TRANSACTION violation reappeared after the next pull.

Root cause: in resolveDuplicates, a duplicate was dropped from the RESOLVE_DUPLICATES payload whenever its transaction thread (childReportID) was missing. Transaction threads are created lazily, so when an admin resolves from the workspace chat without opening each expense, transactionThreadReportIDMap is empty and every duplicate hit the skip → the backend received an empty transactionIDList and held nothing.

Fix (in src/libs/actions/IOU/Duplicate.ts):

  1. The held duplicate's transactionID + hold reportActionID and the comment.hold optimistic update are now added to the payload before the thread check. Only the thread-keyed optimistic hold report action is guarded behind a defined transactionThreadReportID (so we never write to report_actions_undefined).
  2. The kept transaction's dismissed-violation action is guarded the same way — when its thread is missing it is skipped, while dismissedViolationReportActionID is still sent so the backend records the dismissal.
  3. A duplicate with no IOU action at all is still skipped, and the previous comment.hold value is restored on failure.

Unit tests were added for both missing-thread paths (held duplicate and kept transaction) plus the preserved skip when the IOU action is absent.

Fixed Issues

$ #92845
PROPOSAL: #92845 (comment)

Tests

  1. Log in as an admin, create a Collect workspace, and invite a member.
  2. As the member, submit two identical expenses (same amount, merchant, date, currency) to the workspace chat so they are flagged as duplicates.
  3. As the admin, open the workspace chat without opening the individual expenses.
  4. Select a duplicated expense → Resolve duplicatesKeep selected → follow the flow → Confirm.
  5. Verify the "Duplicated transaction" violation is removed, the kept expense stays, and the other duplicate is put on hold.
  6. Reload the app and verify the violation does not reappear.
  • Verify that no errors appear in the JS console

Offline tests

  1. Follow steps 1–3 above, then go offline.
  2. Complete the "Keep selected" → "Confirm" flow while offline.
  3. Verify the violation is removed and the duplicate is held optimistically.
  4. Go back online and verify the state is preserved; if the request fails, verify the violations and holds are rolled back.

QA Steps

Same as tests.

  • 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
Android: mWeb Chrome
iOS: Native

After fix:

REC-20260721134626.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari

After fix:

REC-20260721135136.mp4

@yusufdeveloper2903
yusufdeveloper2903 requested review from a team as code owners July 21, 2026 09:23
@melvin-bot
melvin-bot Bot requested review from heyjennahay and nyomanjyotisa and removed request for a team July 21, 2026 09:23
@melvin-bot

melvin-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

@nyomanjyotisa 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 removed the request for review from a team July 21, 2026 09:23
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