Skip to content

[REVIEW TESTS] [Due for payment 2025-04-14] [$500] Update duplicate detection to be treated as any other violation (i.e. on hold applied) #57941

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

Closed
pecanoro opened this issue Mar 6, 2025 · 41 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 External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement.

Comments

@pecanoro
Copy link
Contributor

pecanoro commented Mar 6, 2025

Part of the project

Main issue: https://github.com/Expensify/Expensify/issues/463946

Feature Description

Duplicate detection is more in line with our RTER Violation pattern (like the pending receipt match violation) than our full Hold pattern. Let's update duplicate detections to be treated more like the warning so that when the approver approves a report with potential duplicates, we won't show the hold modal. To do so, we'll:

  • Stop putting the expenses on HOLD and showing that modal.
  • Update potential duplicates to be RTER Violations (or any other warning violation) instead, simply stopping the expenses from being harvested, but not stopping them from being manually submitted or approved.
  • Show a different message/next step at the top of the expense/report:
  • Update the report's next steps, mirroring the pending receipt pattern:
    "Potential duplicate expenses identified. Review duplicates to enable submission."
  • No change for the expense next steps
  • No change to the RBR, it'll still show as the RTER Violation

Manual Test Steps

Once these updates are implemented, you should be able to run these steps and verify the expected outcomes:

  1. As the submitter, create an expense for $10 with the date of today and ‘Home Depot’ as the merchant
  2. As the submitter, create another expense for $10 with the date of today and ‘Home Depot’ as the merchant
  • Verify that you see RBR on the workspace chat
  • Verify that you see RBR on the report preview in the workspace chat
  • Verify that you see RBR on each expense in the report
  • Verify the next steps in the report header read: “Potential duplicate expenses identified. Review duplicates to enable submission.”
  1. As the submitter, create another expense for $5.
  2. As the submitter, submit the report manually
  3. As the approver, access the report and click ‘Approve’
  • Verify that you’re presented with a modal asking whether you want to Approve only compliant expenses, or approve the entire report.
  • Verify that the options show for the entire report ($25) and one for only the expense without violations ($5).

cc/ @garrettmknight

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021898088991592917027
  • Upwork Job ID: 1898088991592917027
  • Last Price Increase: 2025-03-10
  • Automatic offers:
    • DylanDylann | Reviewer | 106480966
    • nkdengineer | Contributor | 106480968
Issue OwnerCurrent Issue Owner: @garrettmknight
@pecanoro pecanoro self-assigned this Mar 6, 2025
@pecanoro pecanoro added Daily KSv2 Improvement Item broken or needs improvement. Engineering labels Mar 6, 2025
@pecanoro
Copy link
Contributor Author

pecanoro commented Mar 6, 2025

Chatting with @garrettmknight about some details and some tests before opening this up with completed details

@garrettmknight garrettmknight changed the title [HOLD] Update duplicate hold to be treated as any othe rviolation [HOLD] Update duplicate detection to be treated as any other violation (i.e. on hold applied) Mar 7, 2025
@garrettmknight garrettmknight self-assigned this Mar 7, 2025
@garrettmknight garrettmknight added the Bug Something is broken. Auto assigns a BugZero manager. label Mar 7, 2025
Copy link

melvin-bot bot commented Mar 7, 2025

Current assignee @garrettmknight is eligible for the Bug assigner, not assigning anyone new.

@pecanoro pecanoro changed the title [HOLD] Update duplicate detection to be treated as any other violation (i.e. on hold applied) Update duplicate detection to be treated as any other violation (i.e. on hold applied) Mar 7, 2025
@pecanoro pecanoro added the External Added to denote the issue can be worked on by a contributor label Mar 7, 2025
Copy link

melvin-bot bot commented Mar 7, 2025

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

@melvin-bot melvin-bot bot changed the title Update duplicate detection to be treated as any other violation (i.e. on hold applied) [$250] Update duplicate detection to be treated as any other violation (i.e. on hold applied) Mar 7, 2025
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 7, 2025
Copy link

melvin-bot bot commented Mar 7, 2025

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

@garrettmknight garrettmknight changed the title [$250] Update duplicate detection to be treated as any other violation (i.e. on hold applied) [$500] Update duplicate detection to be treated as any other violation (i.e. on hold applied) Mar 10, 2025
@melvin-bot melvin-bot bot added the Overdue label Mar 10, 2025
Copy link

melvin-bot bot commented Mar 10, 2025

Upwork job price has been updated to $500

@garrettmknight
Copy link
Contributor

I think this is a bit more complicated than most, so let's up the bounty.

@nkdengineer
Copy link
Contributor

Proposal

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

Update duplicate detection to be treated as any other violation (i.e. on hold applied)

What is the root cause of that problem?

This is an improvement

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

Stop putting the expenses on HOLD and showing that modal.

  1. We need to remove the isDuplicate from isOnHold function, then it will not show the hold modal

return !!transaction.comment?.hold || isDuplicate(transaction.transactionID, true);

Update the report's next steps, mirroring the pending receipt pattern:
"Potential duplicate expenses identified. Review duplicates to enable submission."

  1. Defined a hasDuplicateTransaction function.
function hasDuplicateTransactions(iouReportID?: string, allReportTransactions?: SearchTransaction[]): boolean {
    const transactionsByIouReportID = getReportTransactions(iouReportID);
    const reportTransactions = allReportTransactions ?? transactionsByIouReportID;

    return reportTransactions.length > 0 && reportTransactions.some((transaction) => isDuplicate(transaction.transactionID, true));
}

And then update in MoneyReportHeader to show another message text

const hasDuplicate = hasDuplicateTransactions(moneyRequestReport?.reportID);
const shouldShowStatusBar =
        hasAllPendingRTERViolations || shouldShowBrokenConnectionViolation || hasOnlyHeldExpenses || hasScanningReceipt || isPayAtEndExpense || hasOnlyPendingTransactions || hasDuplicate;

const getStatusBarProps: () => MoneyRequestHeaderStatusBarProps | undefined = () => {
   ...
   if (hasDuplicate) {
        return {icon: getStatusIcon(Expensicons.Hourglass), description: 'Potential duplicate expenses identified. Review duplicates to enable submission.'};
    }
}

Update potential duplicates to be RTER Violations (or any other warning violation) instead, simply stopping the expenses from being harvested, but not stopping them from being manually submitted or approved.

  1. I'm not sure what we need to do in this part

Verify that you’re presented with a modal asking whether you want to Approve only compliant expenses, or approve the entire report.
Verify that the options show for the entire report ($25) and one for only the expense without violations ($5).

  1. We need to update the flow to display the approval confirm modal to contain the duplicate report check
  • Update the condition here to also display the confirm modal if we have duplicate transaction

} else if (isAnyTransactionOnHold) {

  • Update the condition here to get the hold/duplicate transactions/reportActions for Onyx data when we only pay/approve partially

if (transaction?.comment?.hold) {

  1. To display the correct nonHeld amount, we need to make a backend change to update the unheldTotal to not include the amount of the duplicate transaction like we did for the hold transaction. For example, in the test case above the unheldTotal of the expense report should be -500

nonHeldAmount: convertToDisplayString(unheldTotal * coefficient, iouReport?.currency),

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

None

What alternative solutions did you explore? (Optional)

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.

Copy link

melvin-bot bot commented Mar 11, 2025

@DylanDylann Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@pecanoro
Copy link
Contributor Author

@DylanDylann What do you think? I think we can go with @nkdengineer but I would love for you to double-check everything

@DylanDylann
Copy link
Contributor

On my list today. I will review it asap

@melvin-bot melvin-bot bot removed the Overdue label Mar 11, 2025
@DylanDylann
Copy link
Contributor

I just read the description and checked @nkdengineer's proposal. Overall, he gave a correct direction to implement this feature. But some things aren't clear. Anyways, this seems to require lots of change. Thus, I think we can bring these discussions on the PR phase to speed it up.

Given that, let's go with @nkdengineer

🎀 👀 🎀 C+ Reviewed

Copy link

melvin-bot bot commented Mar 11, 2025

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

@pecanoro
Copy link
Contributor Author

Assigning @nkdengineer to the issue

@garrettmknight
Copy link
Contributor

@nkdengineer / @DylanDylann can we update the icon from an exclamation point to a flag before paying this one out? #58387 (comment)

@nkdengineer
Copy link
Contributor

@garrettmknight Sure. Will open a follow-up PR soon.

@nkdengineer
Copy link
Contributor

@garrettmknight Here is the flag icon we want right.

Image

@garrettmknight
Copy link
Contributor

Yep, that's the one. Thanks!

@nkdengineer nkdengineer mentioned this issue Apr 2, 2025
50 tasks
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Weekly KSv2 labels Apr 2, 2025
@nkdengineer
Copy link
Contributor

@DylanDylann The follow-up PR is ready for review. cc @garrettmknight

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Apr 7, 2025
@melvin-bot melvin-bot bot changed the title [Due for payment 2025-04-08] [$500] Update duplicate detection to be treated as any other violation (i.e. on hold applied) [Due for payment 2025-04-14] [Due for payment 2025-04-08] [$500] Update duplicate detection to be treated as any other violation (i.e. on hold applied) Apr 7, 2025
Copy link

melvin-bot bot commented Apr 7, 2025

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

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

melvin-bot bot commented Apr 7, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.23-7 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 2025-04-14. 🎊

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

Copy link

melvin-bot bot commented Apr 7, 2025

@DylanDylann @garrettmknight @DylanDylann The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Apr 8, 2025
@garrettmknight
Copy link
Contributor

Thanks! I don't think we need the checklist for this one since it's a new feature. I'll pay out, but I'll leave this open to check out testrails for hold to make sure we aren't testing for the old functionality.

@melvin-bot melvin-bot bot removed the Overdue label Apr 10, 2025
@garrettmknight
Copy link
Contributor

Paid! Thanks for the quick work.

@garrettmknight garrettmknight changed the title [Due for payment 2025-04-14] [Due for payment 2025-04-08] [$500] Update duplicate detection to be treated as any other violation (i.e. on hold applied) [REVIEW TESTS] [Due for payment 2025-04-14] [$500] Update duplicate detection to be treated as any other violation (i.e. on hold applied) Apr 10, 2025
@melvin-bot melvin-bot bot added the Overdue label Apr 14, 2025
Copy link

melvin-bot bot commented Apr 14, 2025

@garrettmknight Whoops! This issue is 2 days overdue. Let's get this updated quick!

@garrettmknight
Copy link
Contributor

Still need to review and update test rails.

@melvin-bot melvin-bot bot removed the Overdue label Apr 14, 2025
@garrettmknight
Copy link
Contributor

Alright, found the test case and submitted and issue to update it. Closing!

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 External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement.
Projects
Status: DONE
Development

No branches or pull requests

5 participants