Skip to content

[Due for payment 2026-05-07] [$250] Duplicate - "Potential Duplicate" error displayed despite editing amount on one expense #67116

Closed

Description

@jponikarchuk

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.1.85-5
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: https://test-management.browserstack.com/projects/2148171/test-runs/TR-185/folder/12015289/39317386/801697779
Email or phone of affected tester (no customers): ibellicotest+1403@gmail.com
Issue reported by: Applause Internal Team
Device used: Motorola MotoG60 / Android 12 / Chrome ( mWeb / Hybrid app) - Windows 10 / Chrome
App Component: Money Requests

Action Performed:

Prerequisite: Account has at least one workspace.

  1. Open the Expensify app.
  2. Open any workspace chat.
  3. Create a manual expense.
  4. Create a new report.
  5. Tap on "Add Expense" on the just created report and create an expense similar to the previous one.
  6. Open the first created expense.
  7. Tap on the "Amount" field and edit the amount.
  8. Return to chat.
  9. Note that "Potential duplicate" error appears on the expense that wasn´t edited.
  10. Navigate to "Inbox"
  11. Note that a RBR is displayed on workspace chat.
  12. Reopen workspace chat and open report of the expense with the "Potential Duplicate" error.
  13. Note that the error is cleared.

Expected Result:

After editing the amount on one of the duplicate expenses, the "Potential Duplicate" error shouldn´t appear on the remaining expense.

Actual Result:

When creating two similar expenses and editing the amount on one of them, the "Potential Duplicate" error, appears on the expense that wasn´t edited, despite amounts being different. Error is cleared after opening and closing the expense report.
Issue is reproducible while online and also if the first expense is edited while offline.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

2.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
Issue Owner

Current Issue Owner: @fedirjh

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 24, 2025
  2. melvin-bot commented on Jul 24, 2025

    @melvin-bot

    Triggered auto assignment to @JmillsExpensify (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.

  3. thelullabyy commented on Jul 26, 2025

    @thelullabyy
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Duplicate - "Potential Duplicate" error displayed despite editing amount on one expense

    What is the root cause of that problem?

    When the amount of an expense is updated, we do not re-evaluate or remove the "Potential Duplicate" violation. This logic is missing in the violation update flow:

    App/src/libs/actions/IOU.ts

    Lines 4322 to 4332 in 4b68aa8

    const currentTransactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`] ?? [];
    const violationsOnyxData = ViolationsUtils.getViolationsOnyxData(
    updatedTransaction,
    currentTransactionViolations,
    policy,
    policyTagList ?? {},
    policyCategories ?? {},
    hasDependentTags(policy, policyTagList ?? {}),
    isInvoice,
    );
    optimisticData.push(violationsOnyxData);

    As a result, the violation persists on the related expense even when the condition causing the duplication no longer exists.

    What changes do you think we should make in order to solve the problem?

    We should enhance the logic to detect when the duplicate condition is resolved (e.g., amount is modified), and proactively remove the DUPLICATED_TRANSACTION violation from all involved transactions. This can be done by inserting the following block just below this line:

    App/src/libs/actions/IOU.ts

    Lines 4332 to 4337 in 4b68aa8

    optimisticData.push(violationsOnyxData);
    failureData.push({
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`,
    value: currentTransactionViolations,
    });

    if (duplicateViolation && hasModifiedAmount) {
                const duplicateTransactionIDs = duplicateViolation.data?.duplicates;
                duplicateTransactionIDs?.push(transaction?.transactionID);
                const currentTransactionViolationsData = duplicateTransactionIDs?.map((id) => ({transactionID: id, violations: allTransactionViolations?.[id] ?? []}));
                const optimisticDataTransactionViolations: OnyxUpdate[] = currentTransactionViolationsData?.map((transactionViolations) => ({
                    onyxMethod: Onyx.METHOD.MERGE,
                    key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionViolations.transactionID}`,
                    value: transactionViolations.violations?.filter((violation) => violation.name !== CONST.VIOLATIONS.DUPLICATED_TRANSACTION),
                }));
                optimisticData.push(...optimisticDataTransactionViolations);
                const failureDataTransactionViolations: OnyxUpdate[] = currentTransactionViolationsData?.map((transactionViolations) => ({
                    onyxMethod: Onyx.METHOD.MERGE,
                    key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionViolations.transactionID}`,
                    value: allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`] ?? [],
                }));
                failureData.push(failureDataTransactionViolations);
            }
    

    In addition to amount updates, this logic can be generalized to apply when editing other fields (e.g., currency or merchant) that could invalidate the duplication. We just need to ensure that the condition for resolving the duplicate is met before triggering the violation cleanup.

    Also, we can update snapshot data if needed, similar to what’s done here:

    if (hash) {

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    NA

    What alternative solutions did you explore? (Optional)

  4. JmillsExpensify commented on Jul 30, 2025

    @JmillsExpensify
    Contributor

    Opening up to the community.

  5. changed the title [-]Duplicate - "Potential Duplicate" error displayed despite editing amount on one expense[/-] [+][$250] Duplicate - "Potential Duplicate" error displayed despite editing amount on one expense[/+] on Jul 30, 2025
  6. melvin-bot commented on Jul 30, 2025

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 30, 2025
  8. 157 remaining items

  9. mallenexpensify commented on May 8, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @thelullabyy paid $250 via Upwork
    Contributor+: @aimane-chnaif paid $250 via Upwork

    @aimane-chnaif can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022052881588618217743

    @aimane-chnaif if jobs are offered in Upwork, please accept them. It's a pain to have to create new jobs (basing this of the below).

    Image

    ^ Test case created

  10. aimane-chnaif commented on May 15, 2026

    @aimane-chnaif
    Contributor

    @mallenexpensify accepted offer

  11. mallenexpensify commented on May 16, 2026

    @mallenexpensify
    Contributor

    @aimane-chnaif paid, summary updated above. Thx.

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions