Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.53k stars 2.88k forks source link

Dupe detection - RBR is not shown when creating dupe expense with a Gmail account #52243

Open IuliiaHerets opened 2 hours ago

IuliiaHerets commented 2 hours ago

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: v9.0.59-0 Reproducible in staging?: Y Reproducible in production?: Y Issue was found when executing this PR: https://github.com/Expensify/App/pull/48958 Email or phone of affected tester (no customers): dave0123seife@gmail.com Issue reported by: Applause Internal Team

Action Performed:

  1. Login to an account.
  2. Create a workspace
  3. Open the Workspace chat
  4. Submit an expense in the Workspace with a category,
  5. Submit another expense in the Workspace with a the same amount and merchant in the above but with no category.

Expected Result:

RBR(red dot) is shown in LHN and also in the report because of the dupe expense.

Actual Result:

RBR(red dot) is not shown in LHN and in the report. RBR is only shown inside the expense report

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/6067710d-aceb-409e-b71b-b12145014331

View all open jobs on GitHub

melvin-bot[bot] commented 2 hours ago

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.

bernhardoj commented 1 hour ago

Proposal

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

RBR is not shown on the report preview when money request is dupe.

What is the root cause of that problem?

The RBR doesn't show on the report preview because it only shows if the dupe detection permission is enabled. IF the account doesn't have the permission, then RBR won't show. https://github.com/Expensify/App/blob/5e69bfc36ddfd82a113606257abb93f2fa78f7db/src/components/ReportActionItem/ReportPreview.tsx#L156-L160 https://github.com/Expensify/App/blob/5e69bfc36ddfd82a113606257abb93f2fa78f7db/src/libs/TransactionUtils/index.ts#L832-L842

However, on the individual expense preview, we just checks for the amount of the duplicates violation without checking whether the permission is enabled or not, which is different form hasWarningTypeViolations. https://github.com/Expensify/App/blob/5e69bfc36ddfd82a113606257abb93f2fa78f7db/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx#L147-L149

So, I think there are 2 issues here. In ReportPreview, we check for warning type violation. In MoneyRequestPreviewContent, we don't check for warning type violation, but we check for duplicates, ignoring the dupe detection permission.

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

Let's use hasWarningTypeViolations in MoneyRequestPreviewContent too.

const hasWarningTypeViolations = TransactionUtils.hasWarningTypeViolation(transaction?.transactionID ?? '-1', transactionViolations);
...
const shouldShowRBR = hasNoticeTypeViolations || hasViolations || hasFieldErrors || (!isFullySettled && !isFullyApproved && isOnHold) || hasWarningTypeViolations;

(MoneyRequestPreviewContent also checks for hasNoticeTypeViolation but ReportPreview don't. We can add it to ReportPreview too if needed by adding it to ReportUtils, just like the others, but I don't know how to trigger notice type violation, so not sure.)