Skip to content

[Payment due @daledah] Allow admins to merge card + cash expenses across draft reports - #102438

Merged
stitesExpensify merged 15 commits into
Expensify:mainfrom
youssef-lr:youssef-lr-app-678389-admins-merge
Oct 15, 2026
Merged

stitesExpensify merged 15 commits into
Expensify:mainfrom
youssef-lr:youssef-lr-app-678389-admins-merge

Conversation

@youssef-lr

@youssef-lr youssef-lr commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Admins have always been allowed to merge transactions from different reports in the Spend page. This PR brings this functionality to the expense view, as well as add a system message notifying the submitter of the deleted merged expense.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/678389
PROPOSAL:

Tests

Added unit tests for admin card and cash merges across reports.

Offline tests

  1. As an admin, go offline, open a card expense on one draft report, tap Merge — verify cash expenses from other draft reports (same submitter, same or different workspace where you are admin) appear as candidates.
  2. Repeat with no cached policy for one workspace — verify its expenses do not appear as candidates.
  3. As a non-admin manager reviewing a processing report, go offline, tap Merge — verify only same-report expenses appear.

QA Steps

  1. As a workspace admin, open a card expense on a draft report, tap Merge — verify cash expenses from other draft reports of the same submitter (same workspace) appear.
  2. As a workspace admin, select a card expense and a cash expense from different draft reports of the same submitter in Search, verify Merge is available.
  3. As a non-admin approver, open a card expense on a submitted (processing) report, tap Merge — verify only other expenses on that same report appear.
  4. As an admin who is also the submitter, tap Merge — verify all own eligible expenses appear (cross-report).
  5. As a workspace admin, merge a submitter's card expense on report A with a cash expense on report B, which also holds another expense — as the submitter, open report B and verify a system message from the admin reads "merged expenses and moved one to Deleted".
  6. Repeat with a cash expense that is the only expense on its report — verify that report is deleted and the system message appears on the report that holds the kept expense.
  7. Switch the language to Spanish — verify the system message is translated.
  • 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
iOS: mWeb Safari
MacOS: Chrome / Safari
admins.merging.card.cash.mov

Remove the same-report shortcut for admins in getTransactionsForMerging.
Admins now discover cross-report and cross-workspace candidates via the
API (online) or the local filter (offline). Only non-admin managers
reviewing a processing report keep the same-report restriction.

The offline filter (getTransactionsForMergingLocally) now resolves admin
access per-candidate against that candidate's own workspace policy.
Candidates are excluded when their workspace policy is absent from the
local cache rather than assumed accessible.

MergeTransactionsListContent subscribes to allPolicies and allReports
and forwards them for the offline per-candidate check.

Tests: 5 new cases covering admin cross-report (same workspace),
non-admin workspace rejection, missing-cache exclusion, manager
same-report restriction, and admin-as-submitter cross-report.
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

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.

Files with missing lines Coverage Δ
src/CONST/index.ts 95.90% <ø> (ø)
src/hooks/useSelectedTransactionsActions.ts 78.62% <ø> (ø)
src/libs/MergeTransactionUtils.ts 91.48% <100.00%> (ø)
...ages/TransactionMerge/DynamicDetailsReviewPage.tsx 83.92% <ø> (ø)
...ages/TransactionMerge/DynamicReceiptReviewPage.tsx 0.00% <ø> (ø)
src/hooks/useSearchBulkActions.ts 80.14% <0.00%> (ø)
...box/report/actionContents/SimpleMessageContent.tsx 92.15% <50.00%> (-1.73%) ⬇️
src/libs/actions/MergeTransaction.ts 90.38% <86.66%> (+5.88%) ⬆️
.../TransactionMerge/MergeTransactionsListContent.tsx 0.00% <0.00%> (ø)
... and 11 files with indirect coverage changes

@youssef-lr
youssef-lr force-pushed the youssef-lr-app-678389-admins-merge branch from 3fd0cf5 to e9cbf48 Compare September 28, 2026 17:17
@youssef-lr youssef-lr changed the title [HOLD] Allow admins to merge card + cash expenses across draft reports Allow admins to merge card + cash expenses across draft reports Sep 28, 2026
@youssef-lr
youssef-lr marked this pull request as ready for review September 28, 2026 19:42
@youssef-lr
youssef-lr requested review from a team as code owners September 28, 2026 19:42
@melvin-bot
melvin-bot Bot requested review from daledah and flaviadefaria and removed request for a team and flaviadefaria September 28, 2026 19:42
@melvin-bot

melvin-bot Bot commented Sep 28, 2026

Copy link
Copy Markdown

@daledah 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 September 28, 2026 19:42
@daledah

daledah commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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 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.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

iOS: HybridApp
ios.mov
MacOS: Chrome / Safari
Screen.Recording.2026-09-29.at.16.45.20.mov

Comment thread src/libs/actions/MergeTransaction.ts Outdated
Comment thread src/pages/TransactionMerge/MergeTransactionsListContent.tsx Outdated
@youssef-lr youssef-lr changed the title Allow admins to merge card + cash expenses across draft reports [HOLD] Allow admins to merge card + cash expenses across draft reports Sep 29, 2026
@youssef-lr

Copy link
Copy Markdown
Contributor Author

This is pending an internal discussion.

@melvin-bot

melvin-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx bun ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx bun ./scripts/generateTranslations.ts --compare-ref main

@youssef-lr
youssef-lr requested a review from daledah October 12, 2026 13:01
@youssef-lr

Copy link
Copy Markdown
Contributor Author

Ready again @daledah

@daledah daledah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@melvin-bot
melvin-bot Bot requested a review from stitesExpensify October 13, 2026 07:23
@melvin-bot melvin-bot Bot changed the title Allow admins to merge card + cash expenses across draft reports [Payment due @daledah] Allow admins to merge card + cash expenses across draft reports Oct 13, 2026
@melvin-bot

melvin-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown

🎯 @daledah, thanks for reviewing and testing this PR! 🎉

A payment issue will be created for your review once this PR is deployed to production.
E/E issue linked to the PR - https://www.github.com/Expensify/Expensify/issues/678389.

If payment is not needed (e.g., regression PR review fix etc), react with 👎 to this comment to prevent the payment issue from being created.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 flaviadefaria has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

This comment has been minimized.

@flaviadefaria

Copy link
Copy Markdown
Contributor

Running some tests now and I'm not quite sure when this happens but I sometimes run into an attendee field when merging two expenses. Not sure what the logic is for displaying the attendee option, but I didn't expect to see it if there are no attendees (the field is disabled in the expense) or only one attendee in both or either expenses.

2026-10-13_14-42-03.mp4
2026-10-13_15-03-25.mp4

@flaviadefaria

Copy link
Copy Markdown
Contributor

Other than that which is a small thing, and if needed could be fixed in a separare PR, all looks good!

@youssef-lr

Copy link
Copy Markdown
Contributor Author

Thanks for testing @flaviadefaria! Looking into your comments now.

@youssef-lr

Copy link
Copy Markdown
Contributor Author

Yeah I can reproduce the issues. I think let’s get this fixed in this PR. I’ll update it shortly.

Compare attendees as stored instead of applying the report-owner display
fallback, which is only resolvable for locally loaded reports and made one
side [owner] and the other [] when merging across reports. When either
expense has no attendees, keep the other side's attendees instead of
flagging a conflict. Remove the now-unused owner-fallback parameters.
@youssef-lr

Copy link
Copy Markdown
Contributor Author

Fix pushed. Tested 7 different scenarios locally.

Screen.Recording.2026-10-13.at.14.11.00.mov

@youssef-lr

Copy link
Copy Markdown
Contributor Author

@daledah can you review again please

@youssef-lr
youssef-lr requested a review from daledah October 13, 2026 14:25

@daledah daledah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code changes LGTM and tested well

…-admins-merge

# Conflicts:
#	src/libs/ReportActionsUtils.ts

@stitesExpensify stitesExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty huge PR, but I didn't see anything that looked obviously incorrect or that could cause problems. Excited to get this across the finish line

@stitesExpensify
stitesExpensify merged commit 548d07f into Expensify:main Oct 15, 2026
35 of 36 checks passed
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 stitesExpensify has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/stitesExpensify in version: 9.5.13-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

Yes, this PR needs a help site update. I opened Docs updates for E/A#102438 Let admins merge expenses across a member's reports.

This PR lets workspace admins merge a member's expenses across different reports. That makes this sentence in How to Merge Duplicate Expenses incorrect:

Approvers and Workspace Admins can merge expenses on the same Draft or Outstanding report.

The docs PR splits that sentence into two bullets:

  • Approvers can merge expenses on the same Draft or Outstanding report.
  • Workspace admins can merge a member's expenses across that member's Draft and Outstanding reports.

I didn't document the new "merged expenses and moved one to Deleted" system message, because it already explains itself in the app.

@youssef-lr, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review


view run

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.

6 participants