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
[Awaiting checklist completion] [Splits in NewDot] [$250] Expense - Card expense splits appear as cash expense when split offline #72395
Open the split.
→ The split appears as cash instead of card expense when card transaction is split offline. Amount field shows Cash. Card field is missing.
Go online.
→ The split becomes card transaction after returning online.
Expected Result:
In Step 7, when card expense is split offline, the transaction thread of the split will show the same card details as the original card expense.
Actual Result:
In Step 7, when card expense is split offline, the transaction thread of the split does not show the same card details as the original card expense.
Amount field shows Cash.
Card field is missing. It shows Reimbursable toggle instead of Card field.
Please re-state the problem that we are trying to solve in this issue.
When splitting a card expense while offline, the split transactions incorrectly appear as cash expenses instead of preserving the card transaction type.
What is the root cause of that problem?
The buildOptimisticTransaction function does not preserve card-related fields (managedCard, cardName, cardID, bank, cardNumber, posted) from the existingTransaction when creating new optimistic transactions for splits. This causes split transactions to lose their card transaction properties and appear as cash expenses.
What changes do you think we should make in order to solve the problem?
File: src/libs/TransactionUtils/index.ts
In the buildOptimisticTransaction function:
Check if existingTransaction?.managedCard is truthy to identify card transactions
If true, extract and preserve the card-related fields: bank, cardName, cardNumber, managedCard, cardID, and posted
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
in the TransactionUtilsTest file, Add test cases to verify:
Card-related fields are preserved when building an optimistic transaction from an existing card transaction
Card fields are not added when building from a non-card (cash) transaction
code changes
describe('buildOptimisticTransaction',()=>{it('should preserve card-related fields from existing card transaction',()=>{// Create an existing card transaction with card-related fieldsconstexistingCardTransaction: Transaction={
...generateTransaction(),managedCard: true,bank: 'expensify',cardName: 'Test Card',cardNumber: '1234',cardID: 123,posted: '2023-10-01',};// Build a new optimistic transaction based on the existing card transactionconstnewTransaction=TransactionUtils.buildOptimisticTransaction({existingTransaction: existingCardTransaction,transactionParams: {amount: 200,currency: 'USD',reportID: '1',comment: 'Test split',attendees: [],created: '2023-10-02',},});// Verify that card-related fields are preservedexpect(newTransaction.managedCard).toBe(true);expect(newTransaction.bank).toBe('expensify');expect(newTransaction.cardName).toBe('Test Card');expect(newTransaction.cardNumber).toBe('1234');expect(newTransaction.cardID).toBe(123);expect(newTransaction.posted).toBe('2023-10-01');});it('should not add card fields if existing transaction is not a card transaction',()=>{// Create an existing cash transaction without card-related fieldsconstexistingCashTransaction: Transaction={
...generateTransaction(),};// Build a new optimistic transaction based on the existing cash transactionconstnewTransaction=TransactionUtils.buildOptimisticTransaction({existingTransaction: existingCashTransaction,transactionParams: {amount: 200,currency: 'USD',reportID: '1',comment: 'Test split',attendees: [],created: '2023-10-02',},});// Verify that card-related fields are not presentexpect(newTransaction.managedCard).toBeUndefined();expect(newTransaction.bank).toBeUndefined();expect(newTransaction.cardName).toBeUndefined();expect(newTransaction.cardNumber).toBeUndefined();expect(newTransaction.cardID).toBeUndefined();expect(newTransaction.posted).toBeUndefined();});});
What alternative solutions did you explore? (Optional)
Please re-state the problem that we are trying to solve in this issue.
In Step 7, when card expense is split offline, the transaction thread of the split does not show the same card details as the original card expense.
Amount field shows Cash.
Card field is missing. It shows Reimbursable toggle instead of Card field.
What is the root cause of that problem?
The optimistic transaction doesn't include the card expense data from existingTransaction. We have the logic to merge the existingTransaction with optimisticTransaction here, but it's only applied for distance requests.
// STEP 4: Build optimistic reportActions. We need:
// 1. CREATED action for the chatReport
// 2. CREATED action for the iouReport
// 3. IOU action for the iouReport
// 4. The transaction thread, which requires the iouAction, and CREATED action for the transaction thread
// 5. REPORT_PREVIEW action for the chatReport
// Note: The CREATED action for the IOU report must be optimistically generated before the IOU action so there's no chance that it appears after the IOU action in the chat
What changes do you think we should make in order to solve the problem?
We should also merge the existingTransaction with optimisticTransaction if we're splitting the expense
// STEP 4: Build optimistic reportActions. We need:
// 1. CREATED action for the chatReport
// 2. CREATED action for the iouReport
// 3. IOU action for the iouReport
// 4. The transaction thread, which requires the iouAction, and CREATED action for the transaction thread
// 5. REPORT_PREVIEW action for the chatReport
// Note: The CREATED action for the IOU report must be optimistically generated before the IOU action so there's no chance that it appears after the IOU action in the chat
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
Update saveSplitTransactions test to verify that the split transaction keeps the card data from the original transaction.
What alternative solutions did you explore? (Optional)
We can always merge existingTransaction with optimistic transaction data in buildOptimisticTransaction function
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
changed the title [-]Expense - Card expense splits appear as cash expense when split offline[/-][+][$250] Expense - Card expense splits appear as cash expense when split offline[/+]on Oct 13, 2025
changed the title [-][$250] Expense - Card expense splits appear as cash expense when split offline[/-][+][Splits in NewDot] [$250] Expense - Card expense splits appear as cash expense when split offline[/+]on Oct 13, 2025
changed the title [-][Due for payment 2025-11-03] [Splits in NewDot] [$250] Expense - Card expense splits appear as cash expense when split offline[/-][+][Awaiting checklist completion] [Splits in NewDot] [$250] Expense - Card expense splits appear as cash expense when split offline[/+]on Nov 5, 2025
[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
[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.
@trjExpensify - as I, @twisterdotcom am already assigned to this issue as BZ, could you also check this box to confirm the Payment Summary above. Note that no single individual can both confirm the payment amounts and approve the payment itself due to SOX.
Activity
melvin-bot commentedon Oct 12, 2025
Triggered auto assignment to @twisterdotcom (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.abzokhattab commentedon Oct 12, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
When splitting a card expense while offline, the split transactions incorrectly appear as cash expenses instead of preserving the card transaction type.
What is the root cause of that problem?
The
buildOptimisticTransactionfunction does not preserve card-related fields (managedCard,cardName,cardID,bank,cardNumber,posted) from theexistingTransactionwhen creating new optimistic transactions for splits. This causes split transactions to lose their card transaction properties and appear as cash expenses.What changes do you think we should make in order to solve the problem?
File:
src/libs/TransactionUtils/index.tsIn the
buildOptimisticTransactionfunction:existingTransaction?.managedCardis truthy to identify card transactionsbank,cardName,cardNumber,managedCard,cardID, andpostedso we should modify the return to:
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
in the
TransactionUtilsTestfile, Add test cases to verify:code changes
What alternative solutions did you explore? (Optional)
NA
nkdengineer commentedon Oct 13, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
In Step 7, when card expense is split offline, the transaction thread of the split does not show the same card details as the original card expense.
Amount field shows Cash.
Card field is missing. It shows Reimbursable toggle instead of Card field.
What is the root cause of that problem?
The optimistic transaction doesn't include the card expense data from
existingTransaction. We have the logic to merge theexistingTransactionwithoptimisticTransactionhere, but it's only applied for distance requests.App/src/libs/actions/IOU.ts
Lines 3530 to 3540 in 89c45c9
What changes do you think we should make in order to solve the problem?
We should also merge the
existingTransactionwithoptimisticTransactionif we're splitting the expenseApp/src/libs/actions/IOU.ts
Lines 3530 to 3540 in 89c45c9
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
Update
saveSplitTransactionstest to verify that the split transaction keeps the card data from the original transaction.What alternative solutions did you explore? (Optional)
We can always merge
existingTransactionwith optimistic transaction data inbuildOptimisticTransactionfunctionReminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
[-]Expense - Card expense splits appear as cash expense when split offline[/-][+][$250] Expense - Card expense splits appear as cash expense when split offline[/+]melvin-bot commentedon Oct 13, 2025
Job added to Upwork: https://www.upwork.com/jobs/~021977721126903414051
twisterdotcom commentedon Oct 13, 2025
cc @garrettmknight
melvin-bot commentedon Oct 13, 2025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @hoangzinh (
External)[-][$250] Expense - Card expense splits appear as cash expense when split offline[/-][+][Splits in NewDot] [$250] Expense - Card expense splits appear as cash expense when split offline[/+]24 remaining items
twisterdotcom commentedon Nov 5, 2025
@hoangzinh please complete the checklist
twisterdotcom commentedon Nov 5, 2025
Payment Summary:
[-][Due for payment 2025-11-03] [Splits in NewDot] [$250] Expense - Card expense splits appear as cash expense when split offline[/-][+][Awaiting checklist completion] [Splits in NewDot] [$250] Expense - Card expense splits appear as cash expense when split offline[/+]hoangzinh commentedon Nov 6, 2025
BugZero Checklist:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: https://github.com/Expensify/App/pull/63092/files#r2498488249
[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
[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: https://github.com/Expensify/Expensify/issues/565644
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
Zapier Logs
Run ID: 00040eee-ce18-a801-6dad-5b4788cd6841hoangzinh commentedon Nov 6, 2025
Thanks @twisterdotcom. I requested in ND
nkdengineer commentedon Nov 7, 2025
@twisterdotcom I get paid via NewDot now
twisterdotcom commentedon Nov 7, 2025
@hoangzinh has submitted payment for this report on ND here.
SO: https://stackoverflowteams.com/c/expensify/questions/7582
Zapier Logs
Run ID: 00040eee-fe00-a4db-a2da-f0c7ee41b561trjExpensify commentedon Nov 7, 2025
I can indeed. Payment summary looks correct!
JmillsExpensify commentedon Dec 17, 2025
$250 approved for @nkdengineer