Skip to content

Take 2: Add merge option when selecting transactions in the report page#78233

Merged
mollfpr merged 43 commits intomainfrom
revert-78228-revert-73248-youssef_merge_from_report_page
Dec 29, 2025
Merged

Take 2: Add merge option when selecting transactions in the report page#78233
mollfpr merged 43 commits intomainfrom
revert-78228-revert-73248-youssef_merge_from_report_page

Conversation

@youssef-lr
Copy link
Contributor

@youssef-lr youssef-lr commented Dec 20, 2025

Explanation of Change

Take 2 of bringing Merge to the reports page with the previous blockers below fixed. Previous PR.

Fixed Issues

#74110
#78211
#78208
#78206
#78182
#78195
#78189
#78179
#78194
#78225
#78181 (comment)
#78190
#78174
#78209

Tests

  • Verify that no errors appear in the JS console

See QA section.

Offline tests

Same test steps while offline.

QA Steps

In the tests, editable means that the transaction is unreported, is in a draft report, or is a report that is awaiting the first approval.
For a manager, they can edit transactions where they are currently the manager and the report is in the submitted state.
For admins, they can edit all transactions of the policy where the parent report is either draft, or submitted.

Two editable transactions without receipts
  1. In the Reports page, as a submitter, select two editable transactions (e.g. from a draft report or a report waiting for first-level approval) and verify the Merge option shows up.
  2. Verify you are taken to the details review page.
  3. Select the fields to keep and merge the transactions.
  4. Verify the merge succeeds, the second transaction is deleted, and the first one is kept and updated.
Two editable transactions, one with a receipt
  1. In the Reports page, as a submitter, select two editable transactions (e.g. from a draft report or a report waiting for first-level approval) and verify the Merge option shows up.
  2. Verify you are taken to the details review page.
  3. Select the fields to keep and navigate to the confirmation page.
  4. Verify the available receipt is selected by default.
  5. Verify the merge succeeds, the second transaction is deleted, and the first one is kept and updated.
Two editable card transactions
  1. Select two card transactions.
  2. Verify the Merge option does not appear.
One card transaction and one cash transaction with receipt
  1. Select a card transaction and a cash transaction from an editable report.
  2. Verify the Merge option is available.
  3. Verify the flow skips directly to the details page and does not show the receipt review.
  4. Merge the transactions and verify the card transaction is kept and updated with the cash receipt, and the cash transaction is deleted.
Manager with editable expenses
  1. Select a couple of transactions submitted to you.
  2. Verify the Merge option appears and the merge succeeds.
  3. Select one transaction belonging to the manager and one belonging to a submitter.
  4. Verify the Merge option does not show up.
Admin
  1. Select a couple of transactions from a policy member that belong to a submitted report.
  2. Verify the Merge option appears and the merge succeeds.
  3. Select one transaction belonging to a member and one belonging to another member.
  4. Verify the Merge option does not show up.
Admin with approved transactions
  1. Select a couple of transactions that are in an approved report.
  2. Verify the Merge option does not show up.

Tests from blockers of the previous PR

#78211 – Merchant is shown instead of Distance & Rate field when merging with manual distance expense
  1. Go to staging.new.expensify.com
  2. Go to workspace chat or self DM.
  3. Create a Map distance expense.
  4. Create a Manual distance expense.
  5. Open Map distance expense.
  6. Click More > Merge.
  7. Select Manual distance expense > Continue.
  8. Select merchant from Manual distance expense > Next.
  9. On confirm page, verify Distance and Rate fields are shown.
#78208 – When merging with per diem expense, both receipts show the selected per diem expense

Precondition:

  • Workspace has per diem rates.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create two per diem expenses of different subrate (to have different amount).
  4. Open expense report.
  5. Open any per diem expense.
  6. Click More > Merge.
  7. Select the other per diem expense > Continue.
  8. On receipt selection page, select the second receipt.
  9. Open the first receipt and second receipt.
  10. Verify each receipt in the full page view corresponds to the correct transaction.
#78206 – When merging with failed scan expense, receipt is missing / Amount shows “Scanning”

Bug 1
Precondition:

  • Account has self DM.
  1. Go to staging.new.expensify.com
  2. Go to self DM.
  3. Create a manual expense.
  4. Create a scan expense with invalid receipt that will fail the scan.
  5. Wait for scan to fail.
  6. Open the MANUAL expense.
  7. Click More > Merge.
  8. Select the scan expense > Continue.
  9. Reach the confirm page.

Bug 2
Precondition:

  • Account has self DM.
  1. Go to staging.new.expensify.com
  2. Go to self DM.
  3. Create a manual expense.
  4. Create a scan expense with invalid receipt that will fail the scan.
  5. Wait for scan to fail.
  6. Open the FAILED SCAN expense.
  7. Click More > Merge.
  8. Select the manual expense > Continue.
  9. Reach the confirm page.

Expected:

  • Bug 1: Receipt from the scan expense appears on the confirm page.
  • Bug 2: Amount field shows the amount from the manual expense.
#78195 – Amount can be selected when merging with card expense after opening Reports

Precondition:

  • Workspace has imported card transactions from direct feed in Company cards page.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Open report with card transaction.
  4. Create a manual expense.
  5. Open card transaction.
  6. Click More > Merge.
  7. Select the cash expense > Next (Amount section not shown – expected).
  8. Go to Reports > Expenses.
  9. Return to Inbox.
  10. Go to workspace chat and open the card transaction.
  11. Click More > Merge.
  12. Select the cash expense > Next (Amount section is shown).
  13. Select the amount from cash expense.
  14. Select any other detail > Next.
  15. Click Merge expenses.
  16. Verify amount is not visible for selection.
#78194 – Not here page opens when bulk merging split and non-split expense
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create an expense.
  4. Open the expense report.
  5. Click More > Split > Save.
  6. Create another expense.
  7. Bulk select the new expense and any split.
  8. Click More > Merge.
  9. If Not Here page does not open, bulk select the new expense with another split.
  10. Merge details page opens.
#78190 – Category & Reimbursable missing on confirmation page
  1. Create an unreported expense in self DM with amount = $1
  2. Create another reported expense with amount > $1 (e.g. $10)
  3. Go to the Reports page and sort by amount ascending
  4. Go through the merge process until confirmation page
  5. Verify Category & Reimbursable are shown.
#78189 – Merging cash with card expense causes blank details page / infinite loading

Precondition:

  • Workspace has imported card transactions from direct feed.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Open report with card transaction.
  4. Create a manual expense.
  5. Open cash transaction.
  6. Click More > Merge.
  7. Select the card expense > Next.
  8. Verify details show properly.
  9. Click RHP back button.
  10. Verify previous page does not show infinite loading.
#78182 – Merge option shown when bulk selecting card expenses

Precondition:

  • Workspace has imported card transactions from direct feed.
  1. Go to staging.new.expensify.com
  2. Go to Reports > Expenses.
  3. Select two card expenses.
  4. Verify “Merge” is not shown.
#78181 – Allow merging negative expenses everywhere
  1. Create a negative amount expense, click “More”, verify “Merge” is visible.
  2. Select two negative amount expenses from the reports page.
  3. Verify merge succeeds.
#78179 – Merge option shown when bulk selecting admin and member expenses

Precondition:

  • Admin has invited a member.
  • Member has created an expense.
  1. Go to staging.new.expensify.com
  2. Go to Reports > Expenses.
  3. Select expenses from admin and invited member.
  4. Click dropdown > Merge.
  5. Verify Merge option is hidden.
#78174 – App opens Inbox after merging expenses on Reports
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create two expenses in two different reports.
  4. Go to Reports > Expenses.
  5. Select both expenses via checkbox.
  6. Click dropdown button > Merge.
  7. Select all detail from the second report > Continue.
  8. Click Merge expenses.
  9. Verify the modal is dismissed and you remain in the Reports page.
#78209 – "From" field displayed empty after merging track expense with expense in workspace

Prerequisite 1: Account has a Self DM.
Prerequisite 2: Account has at least one workspace.

  1. Open the Expensify app.
  2. Create a manual expense and submit it to a workspace.
  3. Create another manual expense and submit it to Self DM.
  4. Navigate to "Reports" > "Expenses"
  5. Long tap and select the track expense.
  6. Tap on the dropdown menu and select "Merge"
  7. Select the expense created on workspace.
  8. Keep all the details from expense created in workspace.
  9. Once the merging process is finished, navigate to "Reports" > "Expenses" again.
  10. Resize the window to trigger mobile view: verify "From" user is still visible.

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
  • MacOS: Desktop
  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
  • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
  • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
  • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
  • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
  • 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)
  • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
  • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
  • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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
MacOS: Desktop

@codecov
Copy link

codecov bot commented Dec 20, 2025

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/CONFIG.ts 84.37% <100.00%> (+0.50%) ⬆️
src/CONST/index.ts 83.47% <ø> (ø)
src/components/MoneyRequestHeader.tsx 0.00% <ø> (ø)
src/hooks/useSelectedTransactionsActions.ts 82.03% <100.00%> (+0.27%) ⬆️
src/libs/DebugUtils.ts 68.56% <100.00%> (+0.13%) ⬆️
src/libs/ReportUtils.ts 72.96% <100.00%> (-0.05%) ⬇️
src/libs/SearchUIUtils.ts 58.94% <100.00%> (+0.03%) ⬆️
src/pages/TransactionDuplicate/Confirmation.tsx 0.00% <ø> (ø)
...ges/home/report/ReportActionItemContentCreated.tsx 25.00% <ø> (ø)
...ponents/ReportActionItem/ReportActionItemImage.tsx 70.27% <0.00%> (-0.79%) ⬇️
... and 16 more
... and 6 files with indirect coverage changes

updatedValues.iouRequestType = transaction?.iouRequestType;
if (transaction?.iouRequestType) {
updatedValues.iouRequestType = transaction?.iouRequestType;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Will it cause an issue where we can't clear iouRequestType?

Copy link
Contributor

Choose a reason for hiding this comment

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

@youssef-lr can you also take a look at this concern? TY

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking into this now

function isManagedCardTransaction(transaction: OnyxEntry<Transaction>): boolean {
return !!transaction?.managedCard;
function isManagedCardTransaction(transaction: OnyxEntry<Transaction>, cardList?: CardList): boolean {
return !!transaction?.managedCard || !!(transaction?.cardID && !!cardList?.[transaction.cardID]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use either getTransactionType util or the transactionType in onyx result?

Screenshot 2025-12-23 at 00 02 27

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I missed that. Will update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to keep in mind this though: #70487. Or simply keep merging logic for all type of cards including personal ones until that issue is done? I think I'll go with this for simplicity now. So I'll use either transactionType or the utility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also just noticing, wow, since when did we start returning transactionThreadReportID in the transactions response? I think this is gonna fix a navigation issue after merging

@youssef-lr youssef-lr marked this pull request as ready for review December 23, 2025 03:47
@youssef-lr youssef-lr requested review from a team as code owners December 23, 2025 03:47
@melvin-bot melvin-bot bot requested review from heyjennahay and removed request for a team December 23, 2025 03:47
@youssef-lr
Copy link
Contributor Author

Ready for review @hoangzinh! Please check the QA section for test steps related to all the blockers.

@melvin-bot melvin-bot bot requested review from rlinoz and removed request for a team December 23, 2025 03:48
@mollfpr mollfpr merged commit d081eb9 into main Dec 29, 2025
34 checks passed
@mollfpr mollfpr deleted the revert-78228-revert-73248-youssef_merge_from_report_page branch December 29, 2025 04:13
@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/mollfpr in version: 9.2.88-0 🚀

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

@youssef-lr
Copy link
Contributor Author

youssef-lr commented Dec 29, 2025

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.2.88-7 🚀

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

@dominictb dominictb mentioned this pull request Dec 31, 2025
54 tasks
reportID: string;

/** The policyID of the report */
policyID?: string;
Copy link
Contributor

@DylanDylann DylanDylann Jan 5, 2026

Choose a reason for hiding this comment

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

@youssef-lr We shouldn’t add a new field to SearchTransaction since it’s deprecated. We need to use the Transaction type instead, so I think we should make a small revert for this newly added field.

cc @luacmartins

Copy link
Contributor

@DylanDylann DylanDylann Jan 5, 2026

Choose a reason for hiding this comment

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

@youssef-lr For more context: #73974. In this project, we’re removing SearchTransaction and using the Transaction type instead. So we shouldn’t add new fields that don’t exist on Transaction, unless we add policyID to the Transaction type.

Copy link
Contributor

Choose a reason for hiding this comment

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

If adding policyID to the Transaction type is OK, I can include it in this PR: #77647

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. We should revert this and access the data via the transaction's report.

Copy link
Contributor

Choose a reason for hiding this comment

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

If adding policyID to the Transaction type is OK, I can include it in this PR: #77647

No, we shouldn't do that. We should access it via the transaction's report

*/
function isFromCreditCardImport(transaction: OnyxEntry<Transaction>): boolean {
// This can be set in transactions found in the search snapshot
if (transaction?.transactionType === CONST.SEARCH.TRANSACTION_TYPE.CARD) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Checklist from #81167: the condition transaction?.bank === CONST.COMPANY_CARD.FEED_BANK_NAME.UPLOAD must be checked before transactionType; otherwise we cannot merge the CSV-imported card.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants