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

[$250] Dupe detection - "Keep this one" button appears when there is a paid expense #48366

Closed
6 tasks done
IuliiaHerets opened this issue Aug 30, 2024 · 29 comments
Closed
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Aug 30, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: v9.0.27-0
Reproducible in staging?: Y
Reproducible in production?: N
Email or phone of affected tester (no customers): [email protected]
**Issue reported by:**Applause Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Submit an expense and pay it.
  4. Submit another two same expenses as Step 3.
  5. Go to transaction thread (any expense).
  6. Click Review duplicates.
  7. Note that Keep this one button does not appear when there is a paid expense.
  8. Click Keep all.
  9. Submit another expense that is same as the previous expenses.
  10. Go to transaction thread of the new expense.
  11. Click Review duplicates.
  12. Note that now "Keep this one" button appears for the other two expenses in Step 4 which did not have the button previously and only the newest expense does not have the button.

Expected Result:

"Keep this one" button should not appear for all expenses in Review duplicates flow when there is a paid expense.

Actual Result:

"Keep this one" button appears for all expenses in Review duplicates flow when there is a paid expense.

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

Bug6588098_1725045313385.20240831_025446.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01647e38725804bb80
  • Upwork Job ID: 1829614254279842129
  • Last Price Increase: 2024-08-30
  • Automatic offers:
    • c3024 | Reviewer | 103803663
    • Krishna2323 | Contributor | 103803665
Issue OwnerCurrent Issue Owner: @VictoriaExpensify
@IuliiaHerets IuliiaHerets added DeployBlockerCash This issue or pull request should block deployment Bug Something is broken. Auto assigns a BugZero manager. labels Aug 30, 2024
Copy link

melvin-bot bot commented Aug 30, 2024

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

Copy link

melvin-bot bot commented Aug 30, 2024

Triggered auto assignment to @VictoriaExpensify (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 the Daily KSv2 label Aug 30, 2024
@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Aug 30, 2024
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.

@marcochavezf marcochavezf added Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Aug 30, 2024
@marcochavezf
Copy link
Contributor

Dupe detection is under beta

@marcochavezf marcochavezf added the External Added to denote the issue can be worked on by a contributor label Aug 30, 2024
Copy link

melvin-bot bot commented Aug 30, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01647e38725804bb80

@melvin-bot melvin-bot bot changed the title Dupe detection - "Keep this one" button appears when there is a paid expense [$250] Dupe detection - "Keep this one" button appears when there is a paid expense Aug 30, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 30, 2024
Copy link

melvin-bot bot commented Aug 30, 2024

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

@Nodebrute
Copy link
Contributor

@marcochavezf Could you please update the actual result and expected result? They are same.

@Nodebrute
Copy link
Contributor

Nodebrute commented Aug 30, 2024

Regression from this PR.,Based on this comment it seems we decided to keep this option hidden when there is a submitted expense.

@Krishna2323
Copy link
Contributor

Krishna2323 commented Aug 30, 2024

Edited by proposal-police: This proposal was edited at 2024-08-30 22:12:14 UTC.

Proposal


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

Dupe detection - "Keep this one" button appears when there is a paid expense

What is the root cause of that problem?

  • When we select Keep all first time the duplicate transaction violation is removed and when we review the duplicates second time the allDuplicates & duplicates length will be 0 and shouldShowKeepButton will become true.
    const allDuplicates = useMemo(
    () =>
    transactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction?.transactionID}`]?.find(
    (violation) => violation.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION,
    )?.data?.duplicates ?? [],
    [transaction?.transactionID, transactionViolations],
    );
    // Remove settled transactions from duplicates
    const duplicates = useMemo(() => TransactionUtils.removeSettledAndApprovedTransactions(allDuplicates), [allDuplicates]);
    // When there are no settled transactions in duplicates, show the "Keep this one" button
    const shouldShowKeepButton = allDuplicates.length === duplicates.length;

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


  • If the length of allDuplicates & duplicates is zero, shouldShowKeepButton should become false.
const shouldShowKeepButton = !!(allDuplicates.length && allDuplicates.length === duplicates.length);
// OR
const shouldShowKeepButton = !!(allDuplicates.length && duplicates.length && allDuplicates.length === duplicates.length);

What alternative solutions did you explore? (Optional)

  • As the resolved transactions will not any duplicates because the violatiion is already dismissed, we can use the threadReportID from params const transactionID = TransactionUtils.getTransactionID(route.params.threadReportID ?? '');. We already have reviewingTransactionID so we can use that instead.
  • Then use the new transactionID to get the duplicates.
    const allDuplicates = useMemo(
    () =>
    transactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction?.transactionID}`]?.find(
    (violation) => violation.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION,
    )?.data?.duplicates ?? [],
    [transaction?.transactionID, transactionViolations],
    );
    // Remove settled transactions from duplicates
    const duplicates = useMemo(() => TransactionUtils.removeSettledAndApprovedTransactions(allDuplicates), [allDuplicates]);
    // When there are no settled transactions in duplicates, show the "Keep this one" button
    const shouldShowKeepButton = allDuplicates.length === duplicates.length;

    const reviewingTransactionID = ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction)?.IOUTransactionID ?? '-1' : '-1';

Result

@Krishna2323
Copy link
Contributor

Proposal Updated

  • Added alternative

@c3024
Copy link
Contributor

c3024 commented Aug 31, 2024

Each transaction seems to have its own MoneyRequestPreviewContent, so it looks more appropriate to check the lengths of allDuplicates and duplicates for that transaction, as suggested in the main solution of @Krishna2323's proposal, rather than getting violations from the transaction that led us to the review duplicates modal, as suggested in the alternative solution.

IMO we should proceed with the primary solution suggested by @Krishna2323.

🎀 👀 🎀 C+ Reviewed

Copy link

melvin-bot bot commented Aug 31, 2024

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

@dominictb
Copy link
Contributor

Proposal

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

"Keep this one" button appears for all expenses in Review duplicates flow when there is a paid expense.

What is the root cause of that problem?

  • If there was a paid expense, we want to:
  1. Hide the "Keep this one" button.

  2. Display text "Some of these duplicates have been approved or paid already." below the "Keep all" button.

  • But we are using different conditions to display the above.

With (1), we are using:

const duplicates = useMemo(() => TransactionUtils.removeSettledAndApprovedTransactions(allDuplicates), [allDuplicates]);

With (2), we are using:

const hasSettledOrApprovedTransaction = transactions.some((transaction) => ReportUtils.isSettled(transaction?.reportID) || ReportUtils.isReportApproved(transaction?.reportID));

hence the "Keep this one" button appear in case of B and C.

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

  • To display (1), we should use the same condition as we used with (1), that is:

const hasSettledOrApprovedTransaction = transactions.some((transaction) => ReportUtils.isSettled(transaction?.reportID) || ReportUtils.isReportApproved(transaction?.reportID));

  • In details, we should pass down the hasSettledOrApprovedTransaction in Review page to its childs MoneyRequestPreviewContent, so:
    <DuplicateTransactionsList transactions={transactions} />

    will be:
                <DuplicateTransactionsList hasSettledOrApprovedTransaction={hasSettledOrApprovedTransaction} transactions={transactions} />
  • Then in MoneyRequestPreviewContent, condition:

{isReviewDuplicateTransactionPage && !isSettled && !isApproved && shouldShowKeepButton && (

will be:

            {isReviewDuplicateTransactionPage && !isSettled && !isApproved && !hasSettledOrApprovedTransaction && (

What alternative solutions did you explore? (Optional)

@dominictb
Copy link
Contributor

@c3024 Sorry for my lateness, and you have already reviewed the existing proposal. But can you review my proposal above? It will make the logic more consistent.

@Krishna2323
Copy link
Contributor

@marcochavezf, friendly bump for assignment if you agree with the C+ decision here.

@melvin-bot melvin-bot bot added the Overdue label Sep 3, 2024
@dominictb
Copy link
Contributor

@c3024 Can you check my comment? cc @marcochavezf

Copy link

melvin-bot bot commented Sep 3, 2024

@marcochavezf, @VictoriaExpensify, @c3024 Whoops! This issue is 2 days overdue. Let's get this updated quick!

@marcochavezf
Copy link
Contributor

Hey guys, thanks for the patience here. I agree with @c3024's decision, assigning @Krishna2323 🚀

@dominictb thanks for bringing this up, if we find out that we'd need to include part of your proposal in the final PR, we can make a partial payment :)

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 3, 2024
Copy link

melvin-bot bot commented Sep 3, 2024

📣 @c3024 🎉 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

Copy link

melvin-bot bot commented Sep 3, 2024

📣 @Krishna2323 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@Krishna2323
Copy link
Contributor

@c3024, PR ready for review ^

@VictoriaExpensify
Copy link
Contributor

Bump @c3024 - can you please review @Krishna2323 PR?

@c3024
Copy link
Contributor

c3024 commented Sep 11, 2024

I already reviewed the PR. It was merged and deployed to staging 5 days ago.

@Krishna2323
Copy link
Contributor

@VictoriaExpensify, PR is merged and deployed to staging 5 days ago :)

@c3024
Copy link
Contributor

c3024 commented Sep 14, 2024

PR deployed to production on 11-Sep. Automation failed here and on the PR. I think this should be on HOLD for payment till 18-Sep or 19-Sep.

cc: @VictoriaExpensify

@c3024
Copy link
Contributor

c3024 commented Sep 23, 2024

@VictoriaExpensify, gentle bump for payment. Automation failed here.

@Krishna2323
Copy link
Contributor

@VictoriaExpensify, friendly bump for payment 🫠

@c3024
Copy link
Contributor

c3024 commented Sep 30, 2024

  • [@c3024] The PR that introduced the bug has been identified. Link to the PR: fix: remove settled transactions from duplicates #47479
  • [@c3024] 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/47479/files#r1780524724
  • [@c3024] 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: No discussion was started because this could not have been identified earlier.
  • [@c3024] Determine if we should create a regression test for this bug. Yes
  • [@c3024] 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 proposal

  1. Go to a workspace chat.
  2. Submit an expense and get it paid.
  3. Submit two more expenses with same details (amount, merchant etc.) as Step 2 in the same workspace chat.
  4. Click on the report preview in the workspace chat
  5. Click on any of the transactions to go to transaction thread
  6. Click on "Review duplicates".
  7. Click "Keep all".
  8. Go back to the workspace chat and submit another expense with same details as in Step 2.
  9. Go to the transaction thread of this expense.
  10. Click on "Review duplicates".
  11. Verify "Keep this one" button does not appear for any duplicate expense.

@mallenexpensify
Copy link
Contributor

Contributor: @Krishna2323 paid $250 via Upwork
Contributor+: @c3024 paid $250 via Upwork.

Test case created, thx @c3024 and @Krishna2323

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests

8 participants