Skip to content

migrate merge transaction - #94940

Closed
huult wants to merge 3 commits into
Expensify:mainfrom
huult:83847-migrate-merge-transaction
Closed

migrate merge transaction#94940
huult wants to merge 3 commits into
Expensify:mainfrom
huult:83847-migrate-merge-transaction

Conversation

@huult

@huult huult commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Fixed Issues

$ #83847
PROPOSAL:

Tests

Same QA step

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Open the Expensify app.
  2. Go to the workspace chat and create 2 receipt expenses.
  3. Open one of the expenses and tap More.
  4. Select Merge.
  5. Verify that the merge list page opens and you can navigate back normally.
  6. Select another receipt expense and tap Continue.
  7. Verify that the merge receipt page opens and you can navigate back normally.
  8. Complete the merge options and tap Continue.
  9. Verify that the merge confirmation page opens and you can navigate back normally.
  • 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 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
Screen.Recording.2026-06-30.at.15.56.40.mp4

@huult
huult requested review from a team as code owners June 30, 2026 08:58
@melvin-bot
melvin-bot Bot requested review from flaviadefaria and suneox and removed request for a team June 30, 2026 08:58
@melvin-bot

melvin-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

@suneox 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]

Comment thread src/pages/TransactionMerge/DynamicReceiptReviewPage.tsx Outdated
Comment thread src/pages/TransactionMerge/DynamicDetailsReviewPage.tsx Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 10a83895c5

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/libs/Navigation/linkingConfig/OldRoutes.ts Outdated
@huult

This comment was marked as outdated.

@codecov

codecov Bot commented Jul 1, 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/SCREENS.ts 100.00% <ø> (ø)
src/libs/Navigation/linkingConfig/config.ts 76.92% <ø> (ø)
.../TransactionMerge/MergeTransactionsListContent.tsx 0.00% <0.00%> (ø)
...nsactionMerge/DynamicMergeTransactionsListPage.tsx 0.00% <0.00%> (ø)
src/ROUTES.ts 21.01% <0.00%> (+0.15%) ⬆️
...gation/AppNavigator/ModalStackNavigators/index.tsx 6.64% <0.00%> (ø)
...ages/TransactionMerge/DynamicReceiptReviewPage.tsx 0.00% <0.00%> (ø)
src/libs/actions/MergeTransaction.ts 67.18% <0.00%> (-0.71%) ⬇️
...ages/TransactionMerge/DynamicDetailsReviewPage.tsx 0.00% <0.00%> (ø)
...pages/TransactionMerge/DynamicConfirmationPage.tsx 0.00% <0.00%> (ø)
... and 13 files with indirect coverage changes

@suneox

suneox commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Manual test cases

DYNAMIC_ROUTES.MERGE_TRANSACTION_LIST — Merge list page (select source expense)
Case 1.1 — Entry: Expense report → More → Merge (1 expense) → opens merge list

Target: src/hooks/useExpenseActions.ts:324src/libs/actions/MergeTransaction.ts:80 (PR: getMergeTransactionListRoute).

Precondition: logged in; ≥1 receipt expense in a workspace chat report; Merge visible in the More menu.

// Merge eligibility is DERIVED from transaction type, policy, and report state — use a real test account with receipt expenses in a workspace chat.

UI entry: Workspace chat → open an expense → More (⋯) → Merge.

Steps:

  1. Open the app and log in.
  2. LHN → open a workspace chat with receipt expenses.
  3. Tap an expense → open the expense thread/report.
  4. Tap More (⋯) → select Merge.
  5. Verify the merge list page opens.
  6. Verify the URL contains suffix merge-transaction-list/<transactionID> on the current base path (e.g. /r/<reportID>/merge-transaction-list/<transactionID>), not /merge/<id>?backTo=….
  7. Tap Back → verify it returns to the expense/report; URL no longer has merge-transaction-list/….

Expected: List page opens correctly; new dynamic URL shape; Back strips the suffix. No console errors.

Case 1.2 — Entry: Transaction header → Merge

Target: src/components/MoneyRequestHeaderSecondaryActions.tsx:370.

Precondition: same as Case 1.1; viewing an expense thread with header secondary actions.

Steps:

  1. Open an expense thread from workspace chat.
  2. Tap Merge in the transaction header secondary actions.
  3. Verify the merge list page opens; URL has merge-transaction-list/<transactionID>.
  4. Tap Back → verify return to the expense thread.

Expected: Header entry works like the More menu; back navigation is correct.

Case 1.3 — Entry: Search → select 2 expenses → bulk Merge (skips list)

Target: src/hooks/useSearchBulkActions.ts:2006 (isOnSearch=true).

Precondition: Search has ≥2 receipt expenses eligible for merge.

UI entry: Search (LHN) → filter expenses → select 2 receipts → bulk Merge.

Steps:

  1. Open Search → find 2 eligible receipt expenses.
  2. Select both → tap bulk Merge.
  3. Verify it does not stop on the list page — navigates directly to receipt review (2 receipts) or details/confirmation depending on data.
  4. Verify URL has merge-transaction-list/<id> as base + next suffix; from search, URL includes isOnSearch=true when applicable.
  5. Tap Back → verify return to search context.

Expected: Search bulk merge skips list with 2 transactions; isOnSearch query appears when needed; back navigation returns to search.

Case 1.4 — Entry: Search selected transactions → Merge

Target: src/hooks/useSelectedTransactionsActions.ts:464.

Precondition: search context with selected transactions eligible for merge.

Steps:

  1. In Search, select 1–2 eligible expenses.
  2. Choose Merge from the selected-transactions menu.
  3. Verify correct navigation (list for 1 txn; skip list for 2 txn).
  4. Verify isOnSearch=true in URL when applicable.

Expected: Selected-transactions merge entry works; no regression vs bulk merge.

Case 1.5 — Forward: select source expense from list → receipt/details

Target: src/pages/TransactionMerge/MergeTransactionsListContent.tsx:166 (PR: passes isOnSearch).

Precondition: on merge list page (Case 1.1); ≥1 eligible expense to pick as source.

Steps:

  1. From merge list, tap another expense (source) → Continue.
  2. Verify navigation to receipt review (both have receipts) or details/confirmation.
  3. Verify URL base still contains merge-transaction-list/<transactionID> + new suffix.
  4. Tap Back → verify return to list or previous step.

Expected: Select source from list forwards correctly; isOnSearch passed through (PR fix).

Case 1.6 — Refresh / deeplink restore on new list URL

Target: linkingConfig/config.ts — PR maps DYNAMIC_LIST_PAGEDYNAMIC_ROUTES.MERGE_TRANSACTION_LIST.path.

Precondition: on merge list page; copy full URL from address bar.

Steps:

  1. Reload (Web) or paste URL in a new tab → Enter.
  2. Verify merge list page restores (not home / 404).
  3. Tap Back → verify correct base report/search.

Expected: Refresh + deeplink on new list URL restore the stack correctly.

Case 1.7 — ⚠️ Backward-compat: old URL /merge/<transactionID> (P1 — verify after fix)

Root cause: no OldRoutes redirect; static route merge/:transactionID removed (review.md §P1).

Precondition: logged in; valid transactionID from a prior flow.

Steps:

  1. Paste https://dev.new.expensify.com:8082/merge/<transactionID> → Enter.
  2. Expected behavior (when complete): redirect/open merge list at a valid base (author may use backTo query if present).
  3. ⚠️ Caveat (current PR): if P1 not fixed yet → may fall back to home/Not Found; capture as bug evidence — not PASS yet.

Expected: After author fixes backward-compat → old URL resolves. Record actual behavior for current PR.


DYNAMIC_ROUTES.MERGE_TRANSACTION_RECEIPT — Receipt review (2 receipts)
Case 2.1 — Entry: 2 receipt expenses → bulk Merge → receipt review

Target: src/libs/actions/MergeTransaction.ts:103 (PR: navigateToMergeTransactionScreen(MERGE_TRANSACTION_RECEIPT)).

Precondition: 2 receipt expenses eligible for merge (both have receipt images).

Steps:

  1. Search or report flow → merge 2 receipt expenses (Case 1.3).
  2. Verify Receipt review page opens (two receipts shown).
  3. Verify URL = …/merge-transaction-list/<id>/merge-transaction-receipt (+ ?isOnSearch=true from search).
  4. Tap Back → verify return to list or search/report context.

Expected: Receipt page opens for 2 receipts; back navigation strips suffix correctly.

Case 2.2 — Forward: receipt → confirmation (no field conflicts)

Target: PR DynamicReceiptReviewPage.tsxcreateDynamicRoute(getMergeTransactionDynamicRouteSuffix(MERGE_TRANSACTION_CONFIRMATION)).

Precondition: 2 receipt expenses with identical fields (no conflicts).

Steps:

  1. On receipt review, pick receipt to keep → tap Continue.
  2. Verify Confirmation page opens (skips details).
  3. Verify URL suffix changes to merge-transaction-confirmation.
  4. Tap Back from confirmation → verify return to receipt or previous step.

Expected: Forward receipt → confirmation when no conflicts; no backTo needed.

Case 2.3 — Forward: receipt → details (field conflicts)

Target: PR DynamicReceiptReviewPage.tsx — forward to MERGE_TRANSACTION_DETAILS.

Precondition: 2 receipts with conflicting fields (merchant, amount, category…).

Steps:

  1. On receipt review, pick receipt → Continue.
  2. Verify Details review page opens.
  3. Verify URL suffix = merge-transaction-details.

Expected: Conflict path goes through details.

Case 2.4 — Refresh / deeplink on new receipt URL

Precondition: on receipt review page; copy URL.

Steps:

  1. Reload / paste URL in new tab.
  2. Verify receipt page restores; no 404.
  3. Back → verify stack.

Expected: Deeplink/refresh on receipt suffix works.

Case 2.5 — ⚠️ Backward-compat: old URL /merge/<id>/receipt (P1)

Steps:

  1. Paste https://dev.new.expensify.com:8082/merge/<transactionID>/receipt (optional ?backTo=…) → Enter.
  2. Expected (after fix): redirect to {base}/merge-transaction-list/<id>/merge-transaction-receipt.
  3. ⚠️ Caveat (current PR): initial redirect was removed because base /merge/$1 is dead — record actual behavior.

DYNAMIC_ROUTES.MERGE_TRANSACTION_DETAILS — Details review (resolve conflicts)
Case 3.1 — Entry: 2 expenses with conflicts → details page

Target: src/libs/actions/MergeTransaction.ts:127.

Precondition: 2 eligible expenses with ≥1 conflicting field.

Steps:

  1. Trigger merge of 2 conflicting expenses.
  2. Verify Details review page opens.
  3. Verify URL suffix merge-transaction-details.
  4. Tap Back → verify return to receipt or list/search.

Expected: Details page shows conflict fields; back navigation correct.

Case 3.2 — Forward: details → confirmation (all fields resolved)

Target: PR DynamicDetailsReviewPage.tsxcreateDynamicRoute(getMergeTransactionDynamicRouteSuffix(MERGE_TRANSACTION_CONFIRMATION)).

Precondition: on details page; values chosen for all conflict fields.

Steps:

  1. Resolve all conflict fields.
  2. Tap Continue.
  3. Verify Confirmation page opens.
  4. Verify URL suffix = merge-transaction-confirmation.

Expected: Forward details → confirmation when no errors remain.

Case 3.3 — Refresh / deeplink on new details URL

Precondition: on details page.

Steps:

  1. Reload / deeplink URL with merge-transaction-details.
  2. Verify page restores; merge state loads from Onyx.
  3. Back → verify stack.

Expected: Refresh/deeplink on details suffix OK.

Case 3.4 — ⚠️ Backward-compat: old URL /merge/<id>/details (P1)

Steps:

  1. Paste https://dev.new.expensify.com:8082/merge/<transactionID>/details → Enter.
  2. Expected (after fix): redirect to valid dynamic URL with base.
  3. ⚠️ Caveat (current PR): no working redirect yet.

DYNAMIC_ROUTES.MERGE_TRANSACTION_CONFIRMATION — Confirmation + complete merge
Case 4.1 — Entry: identical expenses → confirmation (skip receipt + details)

Target: src/libs/actions/MergeTransaction.ts:123.

Precondition: 2 identical expenses (no field conflicts).

Steps:

  1. Merge 2 identical expenses (search bulk or list flow).
  2. Verify land directly on Confirmation page.
  3. Verify URL suffix merge-transaction-confirmation.
  4. Tap Back → verify return to previous step.

Expected: Skip path to confirmation works.

Case 4.2 — Complete merge: confirmation → Merge → success

Target: PR DynamicConfirmationPage.tsxmergeTransactionRequest.

Precondition: on confirmation page with valid merge data.

Steps:

  1. Review summary on confirmation page.
  2. Tap Merge (confirm).
  3. Verify merge API success; modal closes / return to report or search.
  4. Verify expenses merged in UI (one expense remains).

Expected: End-to-end merge completes; no stuck state on confirmation.

Case 4.3 — Full happy path (PR QA): workspace chat 2 receipts

Precondition: workspace chat; 2 receipt expenses (matches PR QA steps).

Steps:

  1. Create 2 receipt expenses in workspace chat.
  2. Open one expense → MoreMerge → list page.
  3. Select second expense → Continue → receipt page.
  4. Pick receipt → Continue → details or confirmation.
  5. Complete → confirmation → Merge.
  6. At each step: tap Back and verify back-nav before continuing forward.

Expected: Full PR QA flow passes with new dynamic URLs.

Case 4.4 — Refresh / deeplink on new confirmation URL

Precondition: on confirmation page.

Steps:

  1. Reload / paste confirmation URL.
  2. Verify confirmation restores (merge data from Onyx).
  3. Back → verify stack.

Expected: Deeplink on confirmation suffix OK.

Case 4.5 — ⚠️ Backward-compat: old URL /merge/<id>/confirmation (P1)

Steps:

  1. Paste https://dev.new.expensify.com:8082/merge/<transactionID>/confirmation → Enter.
  2. Expected (after fix): redirect to valid dynamic URL.
  3. ⚠️ Caveat (current PR): no working redirect yet.

@suneox

suneox commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@huult Could you please take a look at test cases 1.7, 2.5, 3.4, and 4.5? They are missing backward compatibility for the /merge/* path change.

@huult
huult force-pushed the 83847-migrate-merge-transaction branch from f4af277 to 9823f3b Compare July 9, 2026 05:02
@huult huult closed this Jul 13, 2026
@suneox suneox mentioned this pull request Jul 17, 2026
53 tasks
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.

2 participants