You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-07-08] [$250] Duplicate resolver - don't show the "Choose if transaction is reimbursable" step if one of the expenses is a managed card transaction #94679
Version Number: v9.4.18-2 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from BrowserStack: No Email or phone of affected tester (no customers): In thread Logs:Logs Issue reported by:@mgrumbles Slack conversation (hyperlinked to channel name): #expensify-bugs
Action Performed:
Create a workspace
Connect a company card feed
Import some transactions
Add a cash expense for one of the transactions
Click "Resolve duplicates" on the expense
Go through the steps and observe "Choose if transaction is reimbursable" is shown as a step
Expected Result:
We should not show that step if one of the selected transactions is a managed card transaction. The card transaction should always be non-reimbursable.
Actual Result:
The user was shown that step > selected reimbursable > and now has a corp card transaction stuck as reimbursable: true with no recourse to fix it in the product.
Workaround:
None in-product, so we have to spend engineering time to fix it via a CQ.
Platforms:
Select the officially supported platforms where the issue was reproduced:
The duplicate resolver decides which review steps to show by comparing field values across the duplicate set in compareDuplicateTransactionFields. For reimbursable, it falls into the generic branch — if the values differ across transactions it adds reimbursable to the change map, which becomes a visible step:
This comparison has no awareness of card transactions. When a manually-added cash expense (reimbursable: true) is a duplicate of a managed company-card transaction (reimbursable: false), the values differ, so the “Choose if transaction is reimbursable” step is shown. The user can pick reimbursable, and that value is persisted on the merged transaction via buildMergeDuplicatesParams → leaving a corporate-card transaction stuck as reimbursable: true with no in-product way to correct it. Company-card transactions must always be non-reimbursable.
What changes do you think we should make in order to solve the problem?
In compareDuplicateTransactionFields, add a dedicated branch for reimbursable (alongside the existing merchant/taxCode/category/tag special-cases) that checks whether any transaction in the set is a managed card transaction using the existing isManagedCardTransaction util:
If transactions.some(isManagedCardTransaction) → set keep.reimbursable = false and do not add it to change.
Otherwise → keep the current behavior (equal → keep, differ → change).
This is sufficient because:
Object.keys(change) is exactly the list of steps shown, so dropping reimbursable from change removes the step everywhere (ReviewReimbursable.tsx, navigation, confirmation all recompute the same result).
keep.reimbursable = false is seeded into the REVIEW_DUPLICATES Onyx state in getReviewNavigationRoute (...comparisonResult.keep), and the merge then reads reviewDuplicates?.reimbursable ?? false → the merged transaction correctly stays non-reimbursable.
Evidence trace
Step list = Object.keys(compareResult.change), recomputed per screen — e.g. ReviewReimbursable.tsx.
reimbursable added to change only when values differ: index.ts:2610-2613.
Alternative considered & rejected: Hiding only the toggle UI in ReviewReimbursable.tsx would still leave reimbursable in change, so the step would still appear in the flow and the value would remain user-driven. Gating at the comparison source is the single correct fix point.
One caveat to verify: this relies on transaction.managedCard being populated on the imported card transaction client-side. Given the repro connects a company-card feed, that should hold, but it's worth confirming during implementation.
What alternative solutions did you explore? (Optional)
Use the narrower isCorporateCardTransaction (managed + liabilityType RESTRICT) instead of isManagedCardTransaction. The issue describes “managed card,” and any centrally-managed card must be non-reimbursable, so the broader isManagedCardTransaction is the better match.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/94679) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
Please re-state the problem that we are trying to solve in this issue.
When resolving duplicate transactions where one of the duplicates is a centrally managed card transaction (Expensify Card or Company Card) and another is a cash expense, the resolver shows the "Choose if transaction is reimbursable" step. If the user selects "Yes", the merged result is a managed card transaction stuck at reimbursable: true, which is an invalid state with no in-product way to correct it. Managed card transactions must always be non-reimbursable, so that step should never appear when any duplicate is a managed card transaction.
What is the root cause of that problem?
The duplicate resolver builds its list of review steps from the change object returned by compareDuplicateTransactionFields in src/libs/TransactionUtils/index.ts. For each field in fieldsToCompare (which includes reimbursable: ['reimbursable']), the function checks whether the value is identical across all transactions. If they match it stores the value in keep (no step), and if they differ it calls processChanges, which writes the field into change and thereby turns it into a review step:
A cash expense is reimbursable: true while a managed card transaction is reimbursable: false. Because the two values differ, areAllFieldsEqualForKey is false, so reimbursable lands in change and the step is rendered. getReviewNavigationRoute routes into the reimbursable page whenever comparisonResult.change.reimbursable exists, and every Review* page derives its step list from Object.keys(compareResult.change) — so there is no guard anywhere that suppresses the step for card transactions.
The downstream consequence is the actual data corruption. When the user picks "Yes", setReviewDuplicatesKey({reimbursable: true}) is stored, and on confirm buildMergeDuplicatesParams reads it straight through with reimbursable: reviewDuplicates?.reimbursable ?? false, so the merge request writes reimbursable: true onto a managed card transaction:
So the root cause is that compareDuplicateTransactionFields treats reimbursable as a freely-editable field even when one of the duplicates is a managed card transaction, where the value is not actually a user choice — it is constrained to false.
What changes do you think we should make in order to solve the problem?
Special-case reimbursable inside the field loop of compareDuplicateTransactionFields so that when any transaction being compared is a managed card transaction, we force the value into keep as false and never add it to change. The codebase already has the exact predicate — isManagedCardTransaction (returns !!transaction?.managedCard, covers both Expensify and Company cards). Add a branch alongside the existing taxCode/category/tag cases:
}elseif(fieldName==='reimbursable'){if(transactions.some((item)=>isManagedCardTransaction(item))){keep[fieldName]=false;// managed card transactions are always non-reimbursable}elseif(areAllFieldsEqualForKey){keep[fieldName]=firstTransaction?.reimbursable;}else{processChanges(fieldName,transactions,keys);}}
The change object never receives a reimbursable key when a managed card is present, so the step disappears in all three consumers (getReviewNavigationRoute, useReviewDuplicatesNavigation, and ReviewReimbursable) without touching their logic. Putting false into keep flows through setReviewDuplicatesKey({...comparisonResult.keep, ...}), so buildMergeDuplicatesParams resolves reimbursable to false and the merged transaction stays non-reimbursable. When no managed card is involved, the existing equal/different behavior is preserved exactly. transactions here is already the result of removeSettledAndApprovedTransactions, so we only inspect the transactions that actually participate in the merge.
Behavior across every duplicate combination:
Duplicate set
some(isManagedCardTransaction)
Result
managed card + cash
true
keep.reimbursable = false, no step (the bug)
managed card + managed card
true
keep.reimbursable = false (already non-reimbursable; also self-heals a corrupt true)
cash + cash
false
existing equal/processChanges logic, step shown when values differ (no regression)
managed card + cash + cash (3-way)
true
keep.reimbursable = false
I used isManagedCardTransaction rather than a broader card check on purpose: isFromCreditCardImport also matches personal-card / CSV imports that can legitimately be reimbursable, and isCorporateCardTransaction is narrower than needed (managed andliabilityType: RESTRICT). Any managed card must be non-reimbursable regardless of liability type, so isManagedCardTransaction (managedCard) is the precise predicate.
I verified this against a real managed company-card transaction duplicated with a cash expense: the pair is {reimbursable: true, managedCard: false} (cash) and {reimbursable: false, managedCard: true} (card), isManagedCardTransaction returns true for the card, and with the guard the reimbursable step is dropped and the outgoing MergeDuplicates request carries reimbursable: false instead of true.
compareDuplicateTransactionFields is pure and unit-testable: managed card + cash with differing reimbursable should yield keep.reimbursable === false with no reimbursable key in change, while cash + cash with differing reimbursable should still surface the step.
What alternative solutions did you explore? (Optional)
Clamp reimbursable to false only at the write boundary in buildMergeDuplicatesParams. That fixes the corrupted data but still displays the misleading reimbursable step, which the issue explicitly asks us to remove — so handling it at the comparison source is the correct fix. A page/navigation-layer guard was also rejected: the step list is regenerated from change keys independently on each Review* page, so it would leave change.reimbursable populated and the merge could still persist a reimbursable card transaction. The comparison-sou
The duplicate resolver decides which review steps to show by diffing the candidate transactions field-by-field in compareDuplicateTransactionFields. reimbursable is one of those fields:
A managed card transaction is always reimbursable: false, while the manually-added cash expense is reimbursable: true. The two values differ, so change.reimbursable is populated, and getReviewNavigationRoute consequently routes the user into the reimbursable step:
So: card txn reimbursable:false + cash txn reimbursable:true → values differ → change.reimbursable set → reimbursable step shown → user can pick "Yes" → the corp card transaction is merged as reimbursable: true with no in-product way to undo it.
This is not platform-specific (the report just happens to be MacOS Chrome) — it is plain comparison logic, so it reproduces everywhere, and it reproduces in production because the step has always been unguarded. The confirmation page re-derives the same compareResult from this exact function (Confirmation.tsx), so the central comparison is the single convergence point for the step decision, the step page, and the final merge.
What changes do you think we should make in order to solve the problem?
Give reimbursable its own branch in compareDuplicateTransactionFields (right beside the existing billable/generic handling at L2610-L2614). When any transaction in the set is a managed card transaction, force-keep false and never add it to change:
Because change.reimbursable stays empty, getReviewNavigationRoute skips the reimbursable step, and because keep.reimbursable = false is persisted via setReviewDuplicatesKey, buildNewTransactionAfterReviewingDuplicates (L2660) merges the card transaction as non-reimbursable. One change fixes the step list, the step page, and the final merge. Minor changes/improvements can be discussed in the PR phase.
What alternative solutions did you explore? (Optional)
Guard the step only at the navigation layer in getReviewNavigationRoute (L109-L111) by checking the duplicates for a managed card. Rejected: that only hides the step — compareResult.change.reimbursable would still be set, Confirmation.tsx re-derives it independently, and keep.reimbursable would never be forced to false, so the merged transaction could still end up reimbursable. Fixing it inside compareDuplicateTransactionFields addresses the root cause at the single source all three consumers read from.
Please re-state the problem that we are trying to solve in this issue.
When a user clicks "Resolve duplicates" on a cash expense that was matched with a managed card transaction, the duplicate review wizard shows a "Choose if transaction is reimbursable" step. This step should never be shown when any of the duplicates is a managed card transaction, because card transactions must always be non-reimbursable. Showing the step allows users to incorrectly mark the merged expense as reimbursable, leaving the corp card transaction stuck as reimbursable: true with no in-product fix.
What is the root cause of that problem?
In src/libs/TransactionPreviewUtils.ts at lines 109–111, getReviewNavigationRoute routes to the reimbursable review page whenever comparisonResult.change.reimbursable is truthy. That value is produced by compareDuplicateTransactionFields in src/libs/TransactionUtils/index.ts (around line 2506), where reimbursable is listed in fieldsToCompare unconditionally — it compares the raw reimbursable field across all transactions with no check for whether any transaction is a managed card transaction. When a managed card transaction (non-reimbursable) is paired with a cash expense (reimbursable), the values differ and the step is emitted, allowing the user to set an incorrect value.
What changes do you think we should make in order to solve the problem?
src/libs/TransactionUtils/index.ts — compareDuplicateTransactionFields: Before processing the reimbursable field in the fieldsToCompare loop, check whether any transaction in the set is a managed card transaction (using the existing isManagedCardTransaction util). If one is, force reimbursable into keep as false and skip adding it to change, so the step is never surfaced.
src/libs/TransactionPreviewUtils.ts lines 109–111: No change needed to the routing logic itself — fixing the upstream compareDuplicateTransactionFields to never populate change.reimbursable when a managed card is involved is sufficient to prevent this branch from being reached.
src/libs/actions/IOU/Duplicate.ts — resolveDuplicates / mergeDuplicates: Verify (and if needed enforce) that when a managed card transaction is one of the duplicates, the resolved transaction always gets reimbursable: false regardless of what reviewDuplicates contains — as a safety net against any other path that might set reimbursable: true.
What alternative solutions did you explore? (Optional)
Alternatively, gate the reimbursable step in getReviewNavigationRoute directly by checking isManagedCardTransaction on the transaction set before evaluating comparisonResult.change.reimbursable, keeping the comparison logic unchanged.
This is valid for cash-only or non-managed-card duplicates, where reimbursable is a real user choice. It is invalid when any transaction in the duplicate set is a managed card transaction. Managed card transactions are centrally managed company/Expensify card transactions and must always remain non-reimbursable.
So the root cause is not the reimbursable review page itself. The problem is that the duplicate comparison source treats reimbursable as a freely reviewable field even when the duplicate set contains a managed card transaction, where reimbursable is constrained to false.
What changes do you think we should make in order to solve the problem?
Fix this in compareDuplicateTransactionFields(), because this function is the shared source for:
which duplicate review steps are shown;
what values are written into ONYXKEYS.REVIEW_DUPLICATES;
the step list used by the review screens and confirmation screen;
the reviewed values later used by buildMergeDuplicatesParams().
This should happen after removeSettledAndApprovedTransactions() so only the transactions that actually participate in duplicate review/merge affect the decision.
This fixes both sides of the bug:
change.reimbursable is not populated, so getReviewNavigationRoute() skips TRANSACTION_DUPLICATE_REVIEW_REIMBURSABLE_PAGE.
keep.reimbursable = false is written into ONYXKEYS.REVIEW_DUPLICATES, so confirmation and buildMergeDuplicatesParams() use the correct non-reimbursable value.
Do not solve this by hiding the UI step in TransactionPreviewUtils or ReviewReimbursable. That would only hide one consumer while leaving compareDuplicateTransactionFields() and reviewed Onyx state inconsistent.
Also do not use generic card-import checks such as isFromCreditCardImport(). The correct predicate is isManagedCardTransaction(), because personal card imports can still be reimbursable. The invariant applies only to centrally managed card transactions.
As an additional defensive hardening, we can clamp the preview transaction in buildNewTransactionAfterReviewingDuplicates() when the kept/result transaction itself is a managed card transaction:
This is only a safety rail for stale ONYXKEYS.REVIEW_DUPLICATES, old local state, or direct/stale navigation. The comparator remains the real fix because it has access to the full duplicate set. The builder clamp should not replace the comparator logic.
Tests to add
Add coverage for compareDuplicateTransactionFields():
managed card + cash expense with different reimbursable values returns keep.reimbursable === false;
the same case does not return change.reimbursable;
cash-only duplicates with different reimbursable values still return change.reimbursable;
personal card/imported-card transactions without managedCard are not treated as managed card transactions;
settled/approved managed-card duplicates do not force the value if they are filtered out before comparison.
What alternative solutions did you explore? (Optional)
The "Choose if transaction is reimbursable" step is shown purely because the two duplicate transactions disagree on reimbursable, with no awareness that one of them is a centrally managed card transaction (which must always be non-reimbursable).
Every review-duplicates page derives its step list from the keys of the change object returned by compareDuplicateTransactionFields:
Inside compareDuplicateTransactionFields, reimbursable is just another field in fieldsToCompare and falls into the generic comparison branch. The values are compared as raw fields via SafeString(item?.reimbursable), and if they aren't all equal the field gets pushed into change, which is what makes the step appear:
A managed (corp) card transaction carries reimbursable: false, while the manually-added cash expense is reimbursable (reimbursable defaults to true — see getReimbursable). So their raw values differ → change.reimbursable is set → the step renders:
The user then picks "reimbursable", that kept value flows straight into the merge request, and the card transaction is saved as reimbursable: true — an invalid state for a managed card with no in-product way to undo it:
What changes do you think we should make in order to solve the problem?
Fix this in the data layer — compareDuplicateTransactionFields in src/libs/TransactionUtils/index.ts — since it's the single source of truth that both the step list and the kept values flow from.
Special-case reimbursable before it reaches the generic compare branch: if any of the transactions being compared is a managed card transaction (isManagedCardTransaction), force the kept value to non-reimbursable and never add it to change:
if (transactions.some(isManagedCardTransaction)) { keep.reimbursable = false; continue; } (handle this inside a fieldName === 'reimbursable' case, before the generic else).
Because every Review* page builds stepNames from Object.keys(change), removing reimbursable from change automatically drops the step from the flow and the step counter — no changes needed in useReviewDuplicatesNavigation or CONST.REVIEW_DUPLICATES_ORDER. Putting it in keep as false guarantees the merged transaction stays non-reimbursable, which is the expected result (and is consistent with the reimbursable: reviewDuplicates?.reimbursable ?? false default already used when building the merge params).
Edge cases this touches:
Card-vs-card duplicates: both are already non-reimbursable, so the step never showed — unchanged.
Cash-vs-cash duplicates: no managed card, so the existing differ/equal logic still runs and the step shows when it should.
What alternative solutions did you explore? (Optional)
Use the broader isFromCreditCardImport detector instead of isManagedCardTransaction. Rejected: isFromCreditCardImport also returns true for personal cards imported via a bank connection, and those can legitimately be reimbursable. Only centrally managed cards (Expensify/Company cards) are guaranteed non-reimbursable, so isManagedCardTransaction is the precise condition.
Hide the step at the page/navigation layer instead of in the compare function. Rejected: the step list is regenerated from change keys independently on each of the seven Review* pages, and the merge consumes the kept values. Filtering at the page layer would mean touching every page and would still leave change.reimbursable populated, so the merge could keep a card transaction reimbursable. Fixing the source function fixes all consumers at once.
Force reimbursable: false only at merge/confirmation time. Rejected: that would still walk the user through a pointless step that visibly contradicts what's saved, whereas the maintainer explicitly asked to not show that step. Suppressing it at the compare layer matches the requested behavior and keeps the UI and the saved value consistent.
The duplicate review flow compares reimbursable exactly like the other editable duplicate fields, but it does not apply the managed-card invariant before creating the review steps.
This started with the duplicate review fields work. PR #41093 added the review flow, and PR #42503 added reimbursable to the fields that can be reviewed. That implementation compares billable and reimbursable generically, with no managed-card exception.
Current code still does the same:
compareDuplicateTransactionFields() always includes reimbursable in fieldsToCompare:
Git history also confirms the intended distinction: PR #84596 changed reimbursable visibility from “any card import” to isManagedCardTransaction() so personal cards can still be reimbursable, while managed/company cards cannot.
What changes do you think we should make in order to solve the problem?
Handle this in compareDuplicateTransactionFields(), because this function decides both which review steps are shown and what values are stored in reviewDuplicates.
Before iterating fields, detect whether any transaction in the duplicate set is managed card. When processing reimbursable, if any transaction is managed card, force keep.reimbursable = false and skip adding reimbursable to change.
managed card + cash expense with different reimbursable values skips /duplicates/review/reimbursable;
the stored/kept reimbursable value is false;
two non-managed transactions with different reimbursable values still show the reimbursable review step.
What alternative solutions did you explore? (Optional)
We could skip the reimbursable page only in getReviewNavigationRoute(), but that only hides the UI. It would not guarantee reviewDuplicates.reimbursable is forced to false before buildMergeDuplicatesParams() builds the merge request. Handling it in compareDuplicateTransactionFields() fixes both the UI step list and the final data used by the merge.
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A — not critical
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Precondition:
Create a workspace and connect a company card feed
Import some transactions
Test:
Add a cash expense matching one of the imported managed card transactions so they are flagged as duplicates
Click "Resolve duplicates" on the expense
Go through the steps
Verify the "Choose if transaction is reimbursable" step is not shown
Complete the merge and verify the resulting transaction is non-reimbursable
Regression: resolve duplicates between two cash expenses with differing reimbursable values and verify the reimbursable step is still shown
Activity
MelvinBot commentedon Jun 26, 2026
Proposal
What is the root cause of that problem?
The duplicate resolver decides which review steps to show by comparing field values across the duplicate set in
compareDuplicateTransactionFields. Forreimbursable, it falls into the generic branch — if the values differ across transactions it addsreimbursableto thechangemap, which becomes a visible step:This comparison has no awareness of card transactions. When a manually-added cash expense (
reimbursable: true) is a duplicate of a managed company-card transaction (reimbursable: false), the values differ, so the “Choose if transaction is reimbursable” step is shown. The user can pick reimbursable, and that value is persisted on the merged transaction viabuildMergeDuplicatesParams→ leaving a corporate-card transaction stuck asreimbursable: truewith no in-product way to correct it. Company-card transactions must always be non-reimbursable.What changes do you think we should make in order to solve the problem?
In
compareDuplicateTransactionFields, add a dedicated branch forreimbursable(alongside the existingmerchant/taxCode/category/tagspecial-cases) that checks whether any transaction in the set is a managed card transaction using the existingisManagedCardTransactionutil:transactions.some(isManagedCardTransaction)→ setkeep.reimbursable = falseand do not add it tochange.keep, differ →change).This is sufficient because:
Object.keys(change)is exactly the list of steps shown, so droppingreimbursablefromchangeremoves the step everywhere (ReviewReimbursable.tsx, navigation, confirmation all recompute the same result).keep.reimbursable = falseis seeded into theREVIEW_DUPLICATESOnyx state ingetReviewNavigationRoute(...comparisonResult.keep), and the merge then readsreviewDuplicates?.reimbursable ?? false→ the merged transaction correctly stays non-reimbursable.Evidence trace
Object.keys(compareResult.change), recomputed per screen — e.g.ReviewReimbursable.tsx.reimbursableadded tochangeonly when values differ:index.ts:2610-2613.isManagedCardTransactionindex.ts:1349(already exported, returns!!transaction?.managedCard).keep→ Onyx seed:TransactionPreviewUtils.ts:80-89.buildMergeDuplicatesParamsindex.ts:2660→reimbursable: reviewDuplicates?.reimbursable ?? false.Alternative considered & rejected: Hiding only the toggle UI in
ReviewReimbursable.tsxwould still leavereimbursableinchange, so the step would still appear in the flow and the value would remain user-driven. Gating at the comparison source is the single correct fix point.One caveat to verify: this relies on
transaction.managedCardbeing populated on the imported card transaction client-side. Given the repro connects a company-card feed, that should hold, but it's worth confirming during implementation.What alternative solutions did you explore? (Optional)
Use the narrower
isCorporateCardTransaction(managed +liabilityTypeRESTRICT) instead ofisManagedCardTransaction. The issue describes “managed card,” and any centrally-managed card must be non-reimbursable, so the broaderisManagedCardTransactionis the better match.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/94679)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
MobileMage commentedon Jun 26, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When resolving duplicate transactions where one of the duplicates is a centrally managed card transaction (Expensify Card or Company Card) and another is a cash expense, the resolver shows the "Choose if transaction is reimbursable" step. If the user selects "Yes", the merged result is a managed card transaction stuck at
reimbursable: true, which is an invalid state with no in-product way to correct it. Managed card transactions must always be non-reimbursable, so that step should never appear when any duplicate is a managed card transaction.What is the root cause of that problem?
The duplicate resolver builds its list of review steps from the
changeobject returned bycompareDuplicateTransactionFieldsinsrc/libs/TransactionUtils/index.ts. For each field infieldsToCompare(which includesreimbursable: ['reimbursable']), the function checks whether the value is identical across all transactions. If they match it stores the value inkeep(no step), and if they differ it callsprocessChanges, which writes the field intochangeand thereby turns it into a review step:App/src/libs/TransactionUtils/index.ts
Lines 2610 to 2614 in 76bc375
A cash expense is
reimbursable: truewhile a managed card transaction isreimbursable: false. Because the two values differ,areAllFieldsEqualForKeyisfalse, soreimbursablelands inchangeand the step is rendered.getReviewNavigationRouteroutes into the reimbursable page whenevercomparisonResult.change.reimbursableexists, and everyReview*page derives its step list fromObject.keys(compareResult.change)— so there is no guard anywhere that suppresses the step for card transactions.The downstream consequence is the actual data corruption. When the user picks "Yes",
setReviewDuplicatesKey({reimbursable: true})is stored, and on confirmbuildMergeDuplicatesParamsreads it straight through withreimbursable: reviewDuplicates?.reimbursable ?? false, so the merge request writesreimbursable: trueonto a managed card transaction:App/src/libs/TransactionUtils/index.ts
Lines 2659 to 2660 in 76bc375
So the root cause is that
compareDuplicateTransactionFieldstreatsreimbursableas a freely-editable field even when one of the duplicates is a managed card transaction, where the value is not actually a user choice — it is constrained tofalse.What changes do you think we should make in order to solve the problem?
Special-case
reimbursableinside the field loop ofcompareDuplicateTransactionFieldsso that when any transaction being compared is a managed card transaction, we force the value intokeepasfalseand never add it tochange. The codebase already has the exact predicate —isManagedCardTransaction(returns!!transaction?.managedCard, covers both Expensify and Company cards). Add a branch alongside the existingtaxCode/category/tagcases:The
changeobject never receives areimbursablekey when a managed card is present, so the step disappears in all three consumers (getReviewNavigationRoute,useReviewDuplicatesNavigation, andReviewReimbursable) without touching their logic. Puttingfalseintokeepflows throughsetReviewDuplicatesKey({...comparisonResult.keep, ...}), sobuildMergeDuplicatesParamsresolvesreimbursabletofalseand the merged transaction stays non-reimbursable. When no managed card is involved, the existing equal/different behavior is preserved exactly.transactionshere is already the result ofremoveSettledAndApprovedTransactions, so we only inspect the transactions that actually participate in the merge.Behavior across every duplicate combination:
some(isManagedCardTransaction)keep.reimbursable = false, no step (the bug)keep.reimbursable = false(already non-reimbursable; also self-heals a corrupttrue)processChangeslogic, step shown when values differ (no regression)keep.reimbursable = falseI used
isManagedCardTransactionrather than a broader card check on purpose:isFromCreditCardImportalso matches personal-card / CSV imports that can legitimately be reimbursable, andisCorporateCardTransactionis narrower than needed (managed andliabilityType: RESTRICT). Any managed card must be non-reimbursable regardless of liability type, soisManagedCardTransaction(managedCard) is the precise predicate.I verified this against a real managed company-card transaction duplicated with a cash expense: the pair is
{reimbursable: true, managedCard: false}(cash) and{reimbursable: false, managedCard: true}(card),isManagedCardTransactionreturnstruefor the card, and with the guard the reimbursable step is dropped and the outgoingMergeDuplicatesrequest carriesreimbursable: falseinstead oftrue.compareDuplicateTransactionFieldsis pure and unit-testable: managed card + cash with differingreimbursableshould yieldkeep.reimbursable === falsewith noreimbursablekey inchange, while cash + cash with differingreimbursableshould still surface the step.What alternative solutions did you explore? (Optional)
Clamp
reimbursabletofalseonly at the write boundary inbuildMergeDuplicatesParams. That fixes the corrupted data but still displays the misleading reimbursable step, which the issue explicitly asks us to remove — so handling it at the comparison source is the correct fix. A page/navigation-layer guard was also rejected: the step list is regenerated fromchangekeys independently on eachReview*page, so it would leavechange.reimbursablepopulated and the merge could still persist a reimbursable card transaction. The comparison-souyusufdeveloper2903 commentedon Jun 26, 2026
Proposal
What is the root cause of that problem?
The duplicate resolver decides which review steps to show by diffing the candidate transactions field-by-field in
compareDuplicateTransactionFields.reimbursableis one of those fields:App/src/libs/TransactionUtils/index.ts
Lines 2492 to 2500 in b396890
It has no dedicated handler, so it falls into the generic branch — if the values are not all equal it is pushed into
changeviaprocessChanges:App/src/libs/TransactionUtils/index.ts
Lines 2610 to 2614 in b396890
A managed card transaction is always
reimbursable: false, while the manually-added cash expense isreimbursable: true. The two values differ, sochange.reimbursableis populated, andgetReviewNavigationRouteconsequently routes the user into the reimbursable step:App/src/libs/TransactionPreviewUtils.ts
Lines 109 to 111 in b396890
App/src/pages/TransactionDuplicate/Review.tsx
Line 191 in b396890
If the user then selects "Yes",
keep.reimbursablebecomestrueand the merged transaction is built non-reimbursable-blind from that key:App/src/libs/TransactionUtils/index.ts
Line 2660 in b396890
So: card txn
reimbursable:false+ cash txnreimbursable:true→ values differ →change.reimbursableset → reimbursable step shown → user can pick "Yes" → the corp card transaction is merged asreimbursable: truewith no in-product way to undo it.This is not platform-specific (the report just happens to be MacOS Chrome) — it is plain comparison logic, so it reproduces everywhere, and it reproduces in production because the step has always been unguarded. The confirmation page re-derives the same
compareResultfrom this exact function (Confirmation.tsx), so the central comparison is the single convergence point for the step decision, the step page, and the final merge.What changes do you think we should make in order to solve the problem?
Give
reimbursableits own branch incompareDuplicateTransactionFields(right beside the existingbillable/generic handling at L2610-L2614). When any transaction in the set is a managed card transaction, force-keepfalseand never add it tochange:isManagedCardTransactionis the existing canonical helper, already defined in this same file, so it is in scope with no new import:App/src/libs/TransactionUtils/index.ts
Lines 1346 to 1351 in b396890
Because
change.reimbursablestays empty,getReviewNavigationRouteskips the reimbursable step, and becausekeep.reimbursable = falseis persisted viasetReviewDuplicatesKey,buildNewTransactionAfterReviewingDuplicates(L2660) merges the card transaction as non-reimbursable. One change fixes the step list, the step page, and the final merge. Minor changes/improvements can be discussed in the PR phase.What alternative solutions did you explore? (Optional)
Guard the step only at the navigation layer in
getReviewNavigationRoute(L109-L111) by checking the duplicates for a managed card. Rejected: that only hides the step —compareResult.change.reimbursablewould still be set,Confirmation.tsxre-derives it independently, andkeep.reimbursablewould never be forced tofalse, so the merged transaction could still end up reimbursable. Fixing it insidecompareDuplicateTransactionFieldsaddresses the root cause at the single source all three consumers read from.aswin-s commentedon Jun 26, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user clicks "Resolve duplicates" on a cash expense that was matched with a managed card transaction, the duplicate review wizard shows a "Choose if transaction is reimbursable" step. This step should never be shown when any of the duplicates is a managed card transaction, because card transactions must always be non-reimbursable. Showing the step allows users to incorrectly mark the merged expense as reimbursable, leaving the corp card transaction stuck as
reimbursable: truewith no in-product fix.What is the root cause of that problem?
In
src/libs/TransactionPreviewUtils.tsat lines 109–111,getReviewNavigationRouteroutes to the reimbursable review page whenevercomparisonResult.change.reimbursableis truthy. That value is produced bycompareDuplicateTransactionFieldsinsrc/libs/TransactionUtils/index.ts(around line 2506), wherereimbursableis listed infieldsToCompareunconditionally — it compares the rawreimbursablefield across all transactions with no check for whether any transaction is a managed card transaction. When a managed card transaction (non-reimbursable) is paired with a cash expense (reimbursable), the values differ and the step is emitted, allowing the user to set an incorrect value.What changes do you think we should make in order to solve the problem?
src/libs/TransactionUtils/index.ts—compareDuplicateTransactionFields: Before processing thereimbursablefield in thefieldsToCompareloop, check whether any transaction in the set is a managed card transaction (using the existingisManagedCardTransactionutil). If one is, forcereimbursableintokeepasfalseand skip adding it tochange, so the step is never surfaced.src/libs/TransactionPreviewUtils.tslines 109–111: No change needed to the routing logic itself — fixing the upstreamcompareDuplicateTransactionFieldsto never populatechange.reimbursablewhen a managed card is involved is sufficient to prevent this branch from being reached.src/libs/actions/IOU/Duplicate.ts—resolveDuplicates/mergeDuplicates: Verify (and if needed enforce) that when a managed card transaction is one of the duplicates, the resolved transaction always getsreimbursable: falseregardless of whatreviewDuplicatescontains — as a safety net against any other path that might setreimbursable: true.What alternative solutions did you explore? (Optional)
Alternatively, gate the reimbursable step in
getReviewNavigationRoutedirectly by checkingisManagedCardTransactionon the transaction set before evaluatingcomparisonResult.change.reimbursable, keeping the comparison logic unchanged.x-dev90 commentedon Jun 26, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-06-26 13:13:23 UTC.
Proposal
What is the root cause of that problem?
compareDuplicateTransactionFields()always includesreimbursablein the generic duplicate comparison list:App/src/libs/TransactionUtils/index.ts
Lines 2492 to 2500 in 76bc375
When the selected transaction and its duplicates have different raw
reimbursablevalues, the generic comparison path addsreimbursabletochange:App/src/libs/TransactionUtils/index.ts
Lines 2610 to 2614 in 76bc375
That
change.reimbursablevalue drives the duplicate review flow.getReviewNavigationRoute()routes to the reimbursable review page whenever it exists:App/src/libs/TransactionPreviewUtils.ts
Lines 80 to 110 in 76bc375
This is valid for cash-only or non-managed-card duplicates, where reimbursable is a real user choice. It is invalid when any transaction in the duplicate set is a managed card transaction. Managed card transactions are centrally managed company/Expensify card transactions and must always remain non-reimbursable.
So the root cause is not the reimbursable review page itself. The problem is that the duplicate comparison source treats
reimbursableas a freely reviewable field even when the duplicate set contains a managed card transaction, wherereimbursableis constrained tofalse.What changes do you think we should make in order to solve the problem?
Fix this in
compareDuplicateTransactionFields(), because this function is the shared source for:ONYXKEYS.REVIEW_DUPLICATES;buildMergeDuplicatesParams().After building the filtered
transactionsarray:compute whether the duplicate set contains a managed card transaction:
Then, inside the
fieldsToCompareloop, before the generic equality/change branch handlesreimbursable, force the managed-card invariant:This should happen after
removeSettledAndApprovedTransactions()so only the transactions that actually participate in duplicate review/merge affect the decision.This fixes both sides of the bug:
change.reimbursableis not populated, sogetReviewNavigationRoute()skipsTRANSACTION_DUPLICATE_REVIEW_REIMBURSABLE_PAGE.keep.reimbursable = falseis written intoONYXKEYS.REVIEW_DUPLICATES, so confirmation andbuildMergeDuplicatesParams()use the correct non-reimbursable value.Do not solve this by hiding the UI step in
TransactionPreviewUtilsorReviewReimbursable. That would only hide one consumer while leavingcompareDuplicateTransactionFields()and reviewed Onyx state inconsistent.Also do not use generic card-import checks such as
isFromCreditCardImport(). The correct predicate isisManagedCardTransaction(), because personal card imports can still be reimbursable. The invariant applies only to centrally managed card transactions.As an additional defensive hardening, we can clamp the preview transaction in
buildNewTransactionAfterReviewingDuplicates()when the kept/result transaction itself is a managed card transaction:This is only a safety rail for stale
ONYXKEYS.REVIEW_DUPLICATES, old local state, or direct/stale navigation. The comparator remains the real fix because it has access to the full duplicate set. The builder clamp should not replace the comparator logic.Tests to add
Add coverage for
compareDuplicateTransactionFields():keep.reimbursable === false;change.reimbursable;change.reimbursable;managedCardare not treated as managed card transactions;What alternative solutions did you explore? (Optional)
lorretheboy commentedon Jun 26, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
Abdulloh0109 commentedon Jun 26, 2026
What is the root cause of that problem?
The "Choose if transaction is reimbursable" step is shown purely because the two duplicate transactions disagree on
reimbursable, with no awareness that one of them is a centrally managed card transaction (which must always be non-reimbursable).Every review-duplicates page derives its step list from the keys of the
changeobject returned bycompareDuplicateTransactionFields:App/src/pages/TransactionDuplicate/ReviewReimbursable.tsx
Lines 38 to 41 in 76bc375
Inside
compareDuplicateTransactionFields,reimbursableis just another field infieldsToCompareand falls into the generic comparison branch. The values are compared as raw fields viaSafeString(item?.reimbursable), and if they aren't all equal the field gets pushed intochange, which is what makes the step appear:App/src/libs/TransactionUtils/index.ts
Lines 2492 to 2500 in 76bc375
App/src/libs/TransactionUtils/index.ts
Lines 2610 to 2613 in 76bc375
A managed (corp) card transaction carries
reimbursable: false, while the manually-added cash expense is reimbursable (reimbursabledefaults totrue— seegetReimbursable). So their raw values differ →change.reimbursableis set → the step renders:App/src/libs/TransactionUtils/index.ts
Lines 1195 to 1196 in 76bc375
The user then picks "reimbursable", that kept value flows straight into the merge request, and the card transaction is saved as
reimbursable: true— an invalid state for a managed card with no in-product way to undo it:App/src/libs/TransactionUtils/index.ts
Lines 2659 to 2660 in 76bc375
There's no special-casing anywhere in
compareDuplicateTransactionFieldsfor card transactions, even though the right detector already exists:App/src/libs/TransactionUtils/index.ts
Lines 1346 to 1351 in 76bc375
What changes do you think we should make in order to solve the problem?
Fix this in the data layer —
compareDuplicateTransactionFieldsinsrc/libs/TransactionUtils/index.ts— since it's the single source of truth that both the step list and the kept values flow from.Special-case
reimbursablebefore it reaches the generic compare branch: if any of the transactions being compared is a managed card transaction (isManagedCardTransaction), force the kept value to non-reimbursable and never add it tochange:if (transactions.some(isManagedCardTransaction)) { keep.reimbursable = false; continue; }(handle this inside afieldName === 'reimbursable'case, before the genericelse).Because every
Review*page buildsstepNamesfromObject.keys(change), removingreimbursablefromchangeautomatically drops the step from the flow and the step counter — no changes needed inuseReviewDuplicatesNavigationorCONST.REVIEW_DUPLICATES_ORDER. Putting it inkeepasfalseguarantees the merged transaction stays non-reimbursable, which is the expected result (and is consistent with thereimbursable: reviewDuplicates?.reimbursable ?? falsedefault already used when building the merge params).Edge cases this touches:
What alternative solutions did you explore? (Optional)
Use the broader
isFromCreditCardImportdetector instead ofisManagedCardTransaction. Rejected:isFromCreditCardImportalso returns true for personal cards imported via a bank connection, and those can legitimately be reimbursable. Only centrally managed cards (Expensify/Company cards) are guaranteed non-reimbursable, soisManagedCardTransactionis the precise condition.Hide the step at the page/navigation layer instead of in the compare function. Rejected: the step list is regenerated from
changekeys independently on each of the sevenReview*pages, and the merge consumes the kept values. Filtering at the page layer would mean touching every page and would still leavechange.reimbursablepopulated, so the merge could keep a card transaction reimbursable. Fixing the source function fixes all consumers at once.Force
reimbursable: falseonly at merge/confirmation time. Rejected: that would still walk the user through a pointless step that visibly contradicts what's saved, whereas the maintainer explicitly asked to not show that step. Suppressing it at the compare layer matches the requested behavior and keeps the UI and the saved value consistent.mukhrr commentedon Jun 26, 2026
Proposal
What is the root cause of that problem?
The duplicate review flow compares
reimbursableexactly like the other editable duplicate fields, but it does not apply the managed-card invariant before creating the review steps.This started with the duplicate review fields work. PR #41093 added the review flow, and PR #42503 added
reimbursableto the fields that can be reviewed. That implementation comparesbillableandreimbursablegenerically, with no managed-card exception.Current code still does the same:
compareDuplicateTransactionFields()always includesreimbursableinfieldsToCompare:App/src/libs/TransactionUtils/index.ts
Lines 2492 to 2500 in 5c494a6
change:App/src/libs/TransactionUtils/index.ts
Lines 2546 to 2553 in 5c494a6
getReviewNavigationRoute()then opens the reimbursable review step whenevercomparisonResult.change.reimbursableexists:App/src/libs/TransactionPreviewUtils.ts
Lines 109 to 110 in 5c494a6
That conflicts with the rest of the app. Similar managed-card cases already hide or block reimbursable editing:
App/src/components/ReportActionItem/MoneyRequestView.tsx
Lines 464 to 468 in 5c494a6
App/src/components/MoneyRequestConfirmationListFooter/hooks/useFooterDerivedFlags.ts
Lines 91 to 92 in 5c494a6
App/src/pages/Search/SearchEditMultiple/SearchEditMultiplePage.tsx
Lines 103 to 108 in 5c494a6
Git history also confirms the intended distinction: PR #84596 changed reimbursable visibility from “any card import” to
isManagedCardTransaction()so personal cards can still be reimbursable, while managed/company cards cannot.What changes do you think we should make in order to solve the problem?
Handle this in
compareDuplicateTransactionFields(), because this function decides both which review steps are shown and what values are stored inreviewDuplicates.Before iterating fields, detect whether any transaction in the duplicate set is managed card. When processing
reimbursable, if any transaction is managed card, forcekeep.reimbursable = falseand skip addingreimbursabletochange.Small diff sketch:
This avoids regression because:
isManagedCardTransaction()and notisFromCreditCardImport(), matching PR Fix Reimbursable toggle hidden for personal card transactions #84596.buildMergeDuplicatesParams()already sendsreviewDuplicates.reimbursable:App/src/libs/TransactionUtils/index.ts
Lines 2659 to 2660 in 5c494a6
Add unit coverage for:
/duplicates/review/reimbursable;reimbursablevalue isfalse;What alternative solutions did you explore? (Optional)
We could skip the reimbursable page only in
getReviewNavigationRoute(), but that only hides the UI. It would not guaranteereviewDuplicates.reimbursableis forced tofalsebeforebuildMergeDuplicatesParams()builds the merge request. Handling it incompareDuplicateTransactionFields()fixes both the UI step list and the final data used by the merge.melvin-bot commentedon Jun 26, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @abzokhattab (
External)38 remaining items
melvin-bot commentedon Jul 7, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Jul 9, 2026
Payment Summary
Contributor+: @abzokhattab due $250 via NewDot
@abzokhattab plz complete the BZ checklist and tag me in a post once you have. Thx
abbasifaizan70 commentedon Jul 9, 2026
@mallenexpensify, you tagged me here wrongly.
mallenexpensify commentedon Jul 13, 2026
Sorry about that @abbasifaizan70 , thx for the ping, updated above
@abzokhattab plz complete the BZ checklist and tag me in a post once you have. Thx
abzokhattab commentedon Jul 13, 2026
BugZero Checklist
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment: Feat/Dupe detection review fields #42503 (comment)
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A — not critical
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
abzokhattab commentedon Jul 13, 2026
@mallenexpensify done
quinthar commentedon Aug 19, 2026
Approved $250 to @abzokhattab