Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD for payment 2024-08-14] [$250] Dupe detect-Incorrect total amount in the expense report, preview & LHN after deleting offline #46449

Closed
6 tasks done
lanitochka17 opened this issue Jul 29, 2024 · 24 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Jul 29, 2024

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.0.14-1
Reproducible in staging?: Y
Reproducible in production?: N
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat
  3. Submit two same expenses
  4. Click on the expense preview in main chat
  5. Click on the first expense (important)
  6. Go offline
  7. Click Review duplicates
  8. Click Keep this one on the second expense (important)
  9. Click Confirm on the confirmation page
  10. Check the total amount in the expense report and also the expense preview in the main chat and LHN

Expected Result:

The total amount in the expense report, and expense preview in the main chat and LHN will update correctly

Actual Result:

In the expense report, the total is 0.00
In the main chat, the expense preview is the sum of two expenses, including the deleted one
In the LHN, the preview for the main chat is 0.00

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6556635_1722284178448.20240730_040603.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01bae72e20bb144f65
  • Upwork Job ID: 1818041683906527046
  • Last Price Increase: 2024-07-29
  • Automatic offers:
    • akinwale | Reviewer | 103331326
Issue OwnerCurrent Issue Owner: @CortneyOfstad / @muttmuure
@lanitochka17 lanitochka17 added DeployBlockerCash This issue or pull request should block deployment DeployBlocker Indicates it should block deploying the API labels Jul 29, 2024
Copy link

melvin-bot bot commented Jul 29, 2024

Triggered auto assignment to @roryabraham (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@lanitochka17
Copy link
Author

We think that this bug might be related to #wave-collect - Release 2

@roryabraham roryabraham removed the DeployBlocker Indicates it should block deploying the API label Jul 29, 2024
@roryabraham
Copy link
Contributor

definitely front-end since it's only for optimistic state

@roryabraham
Copy link
Contributor

confirmed that dupe detection is still behind a beta so demoting this.

@roryabraham roryabraham added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Jul 29, 2024
@melvin-bot melvin-bot bot changed the title Dupe detect-Incorrect total amount in the expense report, preview & LHN after deleting offline [$250] Dupe detect-Incorrect total amount in the expense report, preview & LHN after deleting offline Jul 29, 2024
Copy link

melvin-bot bot commented Jul 29, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01bae72e20bb144f65

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 29, 2024
Copy link

melvin-bot bot commented Jul 29, 2024

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

Copy link

melvin-bot bot commented Jul 29, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @akinwale (External)

@bernhardoj
Copy link
Contributor

Proposal

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

Total amount is incorrect when resolving duplicated transactions.

What is the root cause of that problem?

When merging duplicates, we subtract the current report amount from all the duplicated transaction amounts.

App/src/libs/actions/IOU.ts

Lines 7679 to 7692 in df69c80

const duplicateTransactionTotals = params.transactionIDList.reduce((total, id) => {
const duplicateTransaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${id}`];
if (!duplicateTransaction) {
return total;
}
return total + duplicateTransaction.amount;
}, 0);
const expenseReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${params.reportID}`];
const expenseReportOptimisticData: OnyxUpdate = {
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${params.reportID}`,
value: {
total: (expenseReport?.total ?? 0) - duplicateTransactionTotals,

However, the duplicated transaction array has duplicated items. When we have transactions 1 and 2, open the 1st transaction thread, and press Keep this one on the 2nd transaction, the duplicated transaction array will be [1, 1].

That's because the array contains the duplicates and also the reviewingTransactionID.

const allTransactionIDsDuplicates = [reviewingTransactionID, ...duplicates].filter((id) => id !== transaction?.transactionID);
Transaction.setReviewDuplicatesKey({...comparisonResult.keep, duplicates: allTransactionIDsDuplicates, transactionID: transaction?.transactionID ?? ''});

reviewingTransactionID is the transaction that we are currently reviewing. From the OP steps, we open transaction 1 and press Review duplicates, so the reviewingTransactionID is 1. duplicates contains the duplicated list of transactions. For example, transaction 1 duplicates list is [2], while transaction 2 duplicates list is [1]. Combined, we get [1, 1].

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

Instead of combining reviewingTransactionID and duplicates, we can just use duplicates.

const allTransactionIDsDuplicates = duplicates;

What alternative solutions did you explore? (Optional)

Remove duplicated items from the array.

Array.from(new Set(allTransactionIDsDuplicates))

@akinwale
Copy link
Contributor

@bernhardoj's proposal works here.

🎀👀🎀 C+ reviewed.

Copy link

melvin-bot bot commented Jul 30, 2024

Current assignee @roryabraham is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@roryabraham
Copy link
Contributor

weird, I wrote this code and I recall it working as expected when I tested it. Maybe I made a mistake or something else changed since then. Anyways, LGTM 👍🏼

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Jul 31, 2024
@bernhardoj
Copy link
Contributor

PR is ready

cc: @akinwale

@CortneyOfstad CortneyOfstad removed the Bug Something is broken. Auto assigns a BugZero manager. label Jul 31, 2024
@CortneyOfstad CortneyOfstad removed their assignment Jul 31, 2024
@CortneyOfstad CortneyOfstad added the Bug Something is broken. Auto assigns a BugZero manager. label Jul 31, 2024
Copy link

melvin-bot bot commented Jul 31, 2024

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jul 31, 2024
@CortneyOfstad
Copy link
Contributor

@muttmuure I am heading OoO until Tuesday (Aug. 6) so reassigning to keep eyes on this in the meantime — thanks!

@CortneyOfstad CortneyOfstad self-assigned this Jul 31, 2024
Copy link

melvin-bot bot commented Aug 7, 2024

@akinwale, @CortneyOfstad, @muttmuure, @roryabraham, @bernhardoj Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Aug 7, 2024
@melvin-bot melvin-bot bot changed the title [$250] Dupe detect-Incorrect total amount in the expense report, preview & LHN after deleting offline [HOLD for payment 2024-08-14] [$250] Dupe detect-Incorrect total amount in the expense report, preview & LHN after deleting offline Aug 7, 2024
Copy link

melvin-bot bot commented Aug 7, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Aug 7, 2024
Copy link

melvin-bot bot commented Aug 7, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.17-2 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-08-14. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Aug 7, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@akinwale] The PR that introduced the bug has been identified. Link to the PR:
  • [@akinwale] 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:
  • [@akinwale] A discussion in #expensify-bugs 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:
  • [@akinwale] Determine if we should create a regression test for this bug.
  • [@akinwale] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@CortneyOfstad / @muttmuure] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@akinwale
Copy link
Contributor

  • [@akinwale] The PR that introduced the bug has been identified. Link to the PR:
  • [@akinwale] 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:
  • [@akinwale] A discussion in #expensify-bugs 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:

This was a regression from #42503. Comment.

  • [@akinwale] Determine if we should create a regression test for this bug.
  • [@akinwale] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

Regression Test Steps

  • Launch Expensify
  • Open a workspace chat report
  • Submit two similar expenses (same amount, currency and merchant)
  • Click on the expense preview in the main chat report
  • Click on the first expense
  • Go offline
  • Click Review duplicates
  • Click Keep this one on the second expense
  • Click Confirm on the confirmation page
  • Navigate back to the expense report
  • Verify that the total amount is the same as the selected expense amount
  • Navigate back to the main chat report
  • Verify that the report preview amount is the same as the selected expense amount
  • Navigate back to LHN (on mobile)
  • Verify that the total amount in the LHN for the last message is the same as the selected expense amount

Do we agree 👍 or 👎?

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Aug 14, 2024
@CortneyOfstad
Copy link
Contributor

Payment Summary

@bernhardoj -- to be paid $250 via NewDot
@akinwale -- paid $250 via Upwork

Regression test here

@bernhardoj
Copy link
Contributor

Requested in ND.

@JmillsExpensify
Copy link

$250 approved for @bernhardoj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor
Projects
Status: Done
Development

No branches or pull requests

7 participants