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-06-13] [$500] Reddot pinned chat appears for approver for submitter's failed scanned receipt #37044

Closed
1 of 6 tasks
m-natarajan opened this issue Feb 21, 2024 · 87 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 Internal Requires API changes or must be handled by Expensify staff

Comments

@m-natarajan
Copy link

m-natarajan commented Feb 21, 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: 1.4.43-3
Reproducible in staging?: y
Reproducible in production?: y
Issue reported by: @puneetlath
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1708448202824579

Action Performed:

  1. Create a collect policy in OD as account A
  2. Invite user B as employee
  3. Log in as user B in NewDot
  4. Create a expense report with a invalid receipt to fail the scanning
  5. Log in to user A in NewDot

Expected Result:

No RBR pinned chat appear in the LHN for the error message

Actual Result:

Seeing red dot pinned chat in LHN for submitter's workspace chat as approver

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

Screen Shot 2024-02-21 at 2 06 13 PM

image (10)

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0158b53b3b70327b50
  • Upwork Job ID: 1760383519930896384
  • Last Price Increase: 2024-04-08
  • Automatic offers:
    • dukenv0307 | Contributor | 0
Issue OwnerCurrent Issue Owner: @isabelastisser
@m-natarajan m-natarajan 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 labels Feb 21, 2024
Copy link

melvin-bot bot commented Feb 21, 2024

Triggered auto assignment to @isabelastisser (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot changed the title Reddot pinned chat appears for approver for submitter's failed scanned receipt [$500] Reddot pinned chat appears for approver for submitter's failed scanned receipt Feb 21, 2024
Copy link

melvin-bot bot commented Feb 21, 2024

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

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

melvin-bot bot commented Feb 21, 2024

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

@wildan-m
Copy link
Contributor

wildan-m commented Feb 22, 2024

Proposal

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

What is the root cause of that problem?

Currently errors are not distinguished by owner, so they will show to all users who have access.

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

If the red dot should only be visible to the owner, we can relocate this line:

result.brickRoadIndicator = hasErrors || hasViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '';

below this code:

result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result as Report);

And adjust the logic to:

    result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result as Report);
    result.brickRoadIndicator = (hasErrors || hasViolations) && result.isIOUReportOwner ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '';

If this condition also applies to the workspace switcher, we can place the check here:

    if (doesReportContainErrors && ReportUtils.isIOUOwnedByCurrentUser(report)) {
        return CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR;
    }

If we also want to ignore CONST.BRICK_ROAD_INDICATOR_STATUS.INFO in the workspace switcher, we can modify getBrickRoadForPolicy to:

const getBrickRoadForPolicy = (report: Report, shouldOnlyShowOwnedReport = true): BrickRoad => {
    if(shouldOnlyShowOwnedReport && !ReportUtils.isIOUOwnedByCurrentUser(report))
    {
        return undefined;
    }

What alternative solutions did you explore? (Optional)

@wildan-m
Copy link
Contributor

@eVoloshchak proposal updated.

Add an optional condition if we also want to apply the same rule for the workspace switcher.

@isabelastisser
Copy link
Contributor

Hey @eVoloshchak, can you please review the proposal? Thanks!

@brandonhenry
Copy link
Contributor

brandonhenry commented Feb 23, 2024

Proposal

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

In the current implementation, when a submitter creates an expense report with an invalid receipt that fails to scan, RBR
appears in the LHN only for the submitter of the report.

The expected behavior is:

  • The RBR on the LHN should only show for the user that made the request
  • The RBRs on the report preview, money request preview, and the ones in the money request view, should show to every user that has access to them

What is the root cause of that problem?

The getAllReportErrors function currently does not distinguish between showing RBRs on the LHN vs showing them on report/request previews and the money request view.

function getAllReportErrors(report: OnyxEntry<Report>, reportActions: OnyxEntry<ReportActions>): OnyxCommon.Errors {

Specifically, the ReportUtils.hasSmartscanError check is used to determine if a smartscan error RBR should be shown:

} else if (ReportUtils.hasSmartscanError(Object.values(reportActions ?? {}))) {
    reportActionErrors.smartscan = ErrorUtils.getMicroSecondOnyxError('report.genericSmartscanFailureMessage');
}

} else if (ReportUtils.hasSmartscanError(Object.values(reportActions ?? {}))) {
reportActionErrors.smartscan = ErrorUtils.getMicroSecondOnyxError('report.genericSmartscanFailureMessage');

This adds the RBR for any user that has access to the report actions, regardless of if they are the submitter or not.

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

To meet the requirements of only showing the RBR on the LHN for the submitter, while still showing it for all users on report/request previews and the money request view, I propose:

  1. Create a new function shouldShowLHNErrorForMissingSmartscanFields that checks if the current user is the submitter before calling the existing hasMissingSmartscanFields:
function shouldShowLHNErrorForMissingSmartscanFields(iouReportID) {
  const reportActions = ReportActionsUtils.getAllReportActions(iouReportID);
  const submitterReportActions = _.filter(reportActions, reportAction => 
    reportAction.actorAccountID === currentUserAccountID
  );

  return ReportUtils.hasMissingSmartscanFields(iouReportID);
}
  1. Update getAllReportErrors to use this new function for determining LHN errors:
} else if (shouldShowLHNErrorForMissingSmartscanFields(report?.reportID ?? '')) {
    reportActionErrors.smartscan = ErrorUtils.getMicroSecondOnyxError('report.genericSmartscanFailureMessage');
}
  1. Leave hasMissingSmartscanFields as is, so it continues to be used for showing RBRs on report/request previews and money request view for all users with access.

This separates the logic for showing LHN errors vs preview/money request view errors, to meet the different requirements for each.

@dukenv0307
Copy link
Contributor

dukenv0307 commented Feb 24, 2024

Proposal

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

  • Reddot pinned chat appears for approver for submitter's failed scanned receipt

What is the root cause of that problem?

  • When displaying a RBR, we do not check if the current user is requestor or not, which leads to the bug:
    } else if (ReportUtils.hasSmartscanError(Object.values(reportActions ?? {}))) {
    reportActionErrors.smartscan = ErrorUtils.getMicroSecondOnyxError('report.genericSmartscanFailureMessage');
    }

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

  • Removed

What alternative solutions did you explore? (Optional)

  • We can create a util function to check if the current user is the requestor or not:
     const isRequestor: (reportAction) => currentUserAccountID === reportAction?.actorAccountID
  • Then, we need to fix the RBR LHN in the transaction thread report, expense report and the chat report.
  • The first one is transaction thread report, we need to update this one:
    if (parentReportAction?.actorAccountID === currentUserAccountID && ReportActionUtils.isTransactionThread(parentReportAction)) {

    to:
    if (isRequestor(parentReportAction) && ReportActionUtils.isTransactionThread(parentReportAction)) {
  • The second one is expense report, we need to update hasMissingSmartscanFields in this one:
    if (ReportUtils.hasMissingSmartscanFields(report?.reportID ?? '') && !ReportUtils.isSettled(report?.reportID)) {

    to:
function hasMissingSmartscanFields(iouReportID: string): boolean {
    const reportActions = Object.values(ReportActionsUtils.getAllReportActions(iouReportID));
    return reportActions.some((action)=>{
        if(!ReportActionsUtils.isMoneyRequestAction(action)){
            return false
        }
        const transaction = TransactionUtils.getLinkedTransaction(action)
        return TransactionUtils.hasMissingSmartscanFields(transaction) && isRequestor(action)
    })
}
  • The last one is the chat report. We do not need to update anything in this one:

    } else if (ReportUtils.hasSmartscanError(Object.values(reportActions ?? {}))) {

    because the above change we made for hasMissingSmartscanFields is enough

  • Additionally, we also need to fix the MoneyRequestView based on the comment "The RBRs on the report preview, money request preview, and the ones in the money request view, should show to every user that has access to them.". Do it by remove canEdit in here

  • We can create a additional param in hasMissingSmartscanFields, named isLHN preview to only apply the change with LHN preview message

@Tony-MK
Copy link
Contributor

Tony-MK commented Feb 25, 2024

Proposal

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

Scan - No red dot for transaction thread in LHN when scanning fails

What is the root cause of that problem?

The second condition block, in the getAllReportErrors function, won't be executed because on the approver's app, the report?.ownerAccountID === currentUserAccountID condition will fail.

} else if ((ReportUtils.isIOUReport(report) || ReportUtils.isExpenseReport(report)) && report?.ownerAccountID === currentUserAccountID) {
if (ReportUtils.hasMissingSmartscanFields(report?.reportID ?? '') && !ReportUtils.isSettled(report?.reportID)) {
reportActionErrors.smartscan = ErrorUtils.getMicroSecondOnyxError('report.genericSmartscanFailureMessage');

Hence, the getAllReportErrors function will continue to the third and last condition which will succeed.

This root cause of this issue is caused by the third condition in the getAllReportErrors function since the function does not consider that previous condition failed because report?.ownerAccountID !== currentUserAccountID.

} else if (ReportUtils.hasSmartscanError(Object.values(reportActions ?? {}))) {
reportActionErrors.smartscan = ErrorUtils.getMicroSecondOnyxError('report.genericSmartscanFailureMessage');

Therefore, the third condition will pass because the ReportUtils.hasSmartscanError returned true. After all, the reportActions contain scan errors because the REPORT_PREVIEW action has to display the RBR in this state.

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

In the third condition, we should check if the report action was acted by the current user to prevent scan errors from the reportActions getting assigned to reportActionErrors.smartscan when expense reports do not meet the report?.ownerAccountID === currentUserAccountID condition.

Old Condition

} else if (ReportUtils.hasSmartscanError(Object.values(reportActions ?? {}))) {
reportActionErrors.smartscan = ErrorUtils.getMicroSecondOnyxError('report.genericSmartscanFailureMessage');
}

New Condition

...
else if (
   ReportUtils.hasSmartscanError(
     Object.values(
      reportActions.filter((reportAction) => reportAction.actorAccountId === currentUserId) ?? {}
      )
   )
)
...

@Tony-MK
Copy link
Contributor

Tony-MK commented Feb 25, 2024

This issue was meant to be fixed at #34827.

The expected result was explained in detail in this #34827 (comment) and #34827 (comment) by @cead22.

The issue was closed despite the third expected result is not fulfilled: The expense report should not have the RBR on the LHN for either user

@eVoloshchak
Copy link
Contributor

@Tony-MK, thank you for the added context!
Asking how we should proceed in #34827 (comment)

@dukenv0307
Copy link
Contributor

dukenv0307 commented Feb 26, 2024

@eVoloshchak Also, maybe we have another expected behavior that we need to consider here #27333 (comment)

@cead22
Copy link
Contributor

cead22 commented Feb 26, 2024

@JmillsExpensify do we wanna show RBR on the LHN when receipt scanning fails only to the user requesting money? I think so, and if that's the case, @brandonhenry 's and @dukenv0307 's root cause is accurate

@melvin-bot melvin-bot bot added the Overdue label Feb 28, 2024
Copy link

melvin-bot bot commented Feb 28, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@isabelastisser
Copy link
Contributor

Not overdue. bump @JmillsExpensify on Carlo's question above ^^

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Feb 28, 2024
@isabelastisser
Copy link
Contributor

I DM'd Mills.

@melvin-bot melvin-bot bot removed the Overdue label Mar 4, 2024
@JmillsExpensify
Copy link

@JmillsExpensify do we wanna show RBR on the LHN when receipt scanning fails only to the user requesting money? I think so, and if that's the case, @brandonhenry 's and @dukenv0307 's root cause is accurate

Yes, that's correct. If the receipt scan fails, then we only RBR the LHN of the person that created the request.

@Tony-MK
Copy link
Contributor

Tony-MK commented Mar 4, 2024

Updated Proposal

Proposal Link: #37044 (comment)

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Apr 9, 2024
@dukenv0307
Copy link
Contributor

@eVoloshchak PR #39970 is opened

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels May 3, 2024
Copy link

melvin-bot bot commented May 3, 2024

This issue has not been updated in over 15 days. @cead22, @eVoloshchak, @isabelastisser, @dukenv0307 eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@isabelastisser
Copy link
Contributor

@dukenv0307 @eVoloshchak, any updates?

@eVoloshchak
Copy link
Contributor

@isabelastisser, PR is in review, should be merged fairly soon

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Monthly KSv2 labels Jun 6, 2024
@melvin-bot melvin-bot bot changed the title [$500] Reddot pinned chat appears for approver for submitter's failed scanned receipt [HOLD for payment 2024-06-13] [$500] Reddot pinned chat appears for approver for submitter's failed scanned receipt Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 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 Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.79-11 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-06-13. 🎊

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

Copy link

melvin-bot bot commented Jun 6, 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:

  • [@eVoloshchak / @dukenv0307] The PR that introduced the bug has been identified. Link to the PR:
  • [@eVoloshchak / @dukenv0307] 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:
  • [@eVoloshchak / @dukenv0307] 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:
  • [@eVoloshchak / @dukenv0307] Determine if we should create a regression test for this bug.
  • [@eVoloshchak / @dukenv0307] 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.
  • [@isabelastisser] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 12, 2024
@isabelastisser
Copy link
Contributor

@eVoloshchak, can you please complete the BZ list above? Thanks!

@isabelastisser
Copy link
Contributor

isabelastisser commented Jun 13, 2024

Payment summary:

@eVoloshchak C+ requires payment through NewDot Manual Requests PENDING $500
@dukenv0307 requires payment automatic offer (Contributor) - paid in Upwork. $500

@isabelastisser
Copy link
Contributor

Bump @eVoloshchak to complete the BZ list before I can close the issue. I will also DM you for visibility. Thanks!

@melvin-bot melvin-bot bot added the Overdue label Jun 17, 2024
@eVoloshchak
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: N/A, this was not a bug, rather a change in expected behavior
  • 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: N/A
  • 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: looks like internal discussion has already took place, which has resulted in [HOLD for payment 2024-06-13] [$500] Reddot pinned chat appears for approver for submitter's failed scanned receipt  #37044 (comment)
  • Determine if we should create a regression test for this bug.
    Is it easy to test for this bug? No
    Is the bug related to an important user flow? Yes
    Is it an impactful bug? Yes

@eVoloshchak
Copy link
Contributor

Regression Test Proposal

Test case 1 (to make sure RBR on the LHN is only shown for the user that made the request):

  1. Create a collect policy in OD as account A
  2. Invite user B as employee
  3. Log in as user B in NewDot
  4. Create an expense report with an invalid receipt to fail the scanning
  5. Log in to user A in NewDot
  6. No RBR pinned chat appears in the LHN for the error message
  7. Log in to user B in NewDot
  8. Verify there is RBR pinned chat appearing in the LHN for the error message

Test case 2 (to make sure the RBRs on the report preview, money request preview, and the ones in the money request view are shown to every user that has access to them):

  1. Create a collect policy in OD as account A
  2. Invite user B as employee
  3. Log in as user B in NewDot
  4. Create an expense report with an invalid receipt to fail the scanning
  5. Log in to user A in NewDot
  6. Verify the RBRs on the report preview, money request preview, and the ones in the money request view are shown
  7. Log in to user B in NewDot
  8. Verify the RBRs on the report preview, money request preview, and the ones in the money request view are shown

Do we agree 👍 or 👎

@JmillsExpensify
Copy link

$500 approved for @eVoloshchak

@isabelastisser
Copy link
Contributor

All set!

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 Internal Requires API changes or must be handled by Expensify staff
Projects
Archived in project
Development

No branches or pull requests