Giter Site home page Giter Site logo

[HOLD for payment 2024-08-14] [$250] Dupe detect-Incorrect total amount in the expense report, preview & LHN after deleting offline about app HOT 22 CLOSED

lanitochka17 avatar lanitochka17 commented on August 15, 2024
[HOLD for payment 2024-08-14] [$250] Dupe detect-Incorrect total amount in the expense report, preview & LHN after deleting offline

from app.

Comments (22)

bernhardoj avatar bernhardoj commented on August 15, 2024 1

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))

from app.

roryabraham avatar roryabraham commented on August 15, 2024 1

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 πŸ‘πŸΌ

from app.

melvin-bot avatar melvin-bot commented on August 15, 2024

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

from app.

github-actions avatar github-actions commented on August 15, 2024

πŸ‘‹ 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.

from app.

lanitochka17 avatar lanitochka17 commented on August 15, 2024

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

from app.

roryabraham avatar roryabraham commented on August 15, 2024

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

from app.

roryabraham avatar roryabraham commented on August 15, 2024

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

from app.

melvin-bot avatar melvin-bot commented on August 15, 2024

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

from app.

melvin-bot avatar melvin-bot commented on August 15, 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.

from app.

melvin-bot avatar melvin-bot commented on August 15, 2024

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

from app.

akinwale avatar akinwale commented on August 15, 2024

@bernhardoj's proposal works here.

πŸŽ€πŸ‘€πŸŽ€ C+ reviewed.

from app.

melvin-bot avatar melvin-bot commented on August 15, 2024

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

from app.

melvin-bot avatar melvin-bot commented on August 15, 2024

πŸ“£ @akinwale πŸŽ‰ An offer has been automatically sent to your Upwork account for the Reviewer role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link
Upwork job

from app.

bernhardoj avatar bernhardoj commented on August 15, 2024

PR is ready

cc: @akinwale

from app.

melvin-bot avatar melvin-bot commented on August 15, 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.

from app.

CortneyOfstad avatar CortneyOfstad commented on August 15, 2024

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

from app.

melvin-bot avatar melvin-bot commented on August 15, 2024

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

from app.

melvin-bot avatar melvin-bot commented on August 15, 2024

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

from app.

melvin-bot avatar melvin-bot commented on August 15, 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:

from app.

melvin-bot avatar melvin-bot commented on August 15, 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:

from app.

akinwale avatar akinwale commented on August 15, 2024
  • [@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 πŸ‘Ž?

from app.

CortneyOfstad avatar CortneyOfstad commented on August 15, 2024

Payment Summary

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

Regression test here

from app.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.