Skip to content

[HOLD for payment 2024-01-25] [$250] Scan - Message for Merchant requirement disappears after entering amount for failed scanning #33876

Closed

Description

@kbecciv

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.21-1
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Go to 1:1 DM > + Request money > Scan.
  2. Create a scan request with a receipt that will fail the scanning.
  3. When the scanning fails, navigate to request details page.
  4. Click Amount and enter an amount.

Expected Result:

Error message for merchant will not disappear because the merchant is not entered yet.

Actual Result:

The error message for empty merchant disappears after entering amount.

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

Bug6331379_1704295823459.bandicam_2024-01-03_17-46-38-078__1_.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0164ff788c4c52bbb1
  • Upwork Job ID: 1742581879623811072
  • Last Price Increase: 2024-01-10
  • Automatic offers:
    • shubham1206agra | Reviewer | 28092728
    • namhihi237 | Contributor | 28092729

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jan 3, 2024
  2. changed the title [-]Scan - Message for Merchant requirement disappears after entering amount for failed scanning[/-] [+][$500] Scan - Message for Merchant requirement disappears after entering amount for failed scanning[/+] on Jan 3, 2024
  3. melvin-bot commented on Jan 3, 2024

    @melvin-bot
  4. melvin-bot commented on Jan 3, 2024

    @melvin-bot

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

  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jan 3, 2024
  6. melvin-bot commented on Jan 3, 2024

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  7. melvin-bot commented on Jan 3, 2024

    @melvin-bot

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

  8. namhihi237 commented on Jan 3, 2024

    @namhihi237
    Contributor

    Proposal

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

    Error message for merchant will not disappear because the merchant is not entered yet.

    What is the root cause of that problem?

    In here when we add the amount the function will be return false, so the error on merchant disappear

    function hasMissingSmartscanFields(transaction: OnyxEntry<Transaction>): boolean {
    return Boolean(transaction && hasReceipt(transaction) && !isDistanceRequest(transaction) && !isReceiptBeingScanned(transaction) && areRequiredFieldsEmpty(transaction));
    }

    if (hasReceipt) {
    receiptURIs = ReceiptUtils.getThumbnailAndImageURIs(transaction);
    hasErrors = canEdit && TransactionUtils.hasMissingSmartscanFields(transaction);
    }

    In here the isMerchantMissing is true but isFromExpenseReport is false with chat 1-1.
    function areRequiredFieldsEmpty(transaction: Transaction): boolean {
    const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`] ?? null;
    const isFromExpenseReport = parentReport?.type === CONST.REPORT.TYPE.EXPENSE;
    return (isFromExpenseReport && isMerchantMissing(transaction)) || isAmountMissing(transaction) || isCreatedMissing(transaction);
    }

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

    Based on the expectation, we only required merchant for policy expense chat, so we should add the condition isPolicyExpenseChat here

    brickRoadIndicator={hasErrors && isPolicyExpenseChat && isEmptyMerchant ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''}
    error={hasErrors && isPolicyExpenseChat && isEmptyMerchant ? translate('common.error.enterMerchant') : ''}

    brickRoadIndicator={hasErrors && isEmptyMerchant ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''}
    error={hasErrors && isEmptyMerchant ? translate('common.error.enterMerchant') : ''}
    />

    What alternative solutions did you explore? (Optional)

  9. paultsimura commented on Jan 3, 2024

    @paultsimura
    Contributor

    As per #33786 (comment), the merchant is not required on the 1:1 requests with receipts. So I'd say this is an expected behavior.

    @mountiny could you please confirm/correct?

  10. shubham1206agra commented on Jan 3, 2024

    @shubham1206agra
    Contributor

    @mountiny Should we show error on merchant if the merchant is no longer required?

  11. paultsimura commented on Jan 3, 2024

    @paultsimura
    Contributor

    Proposal

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

    The merchant error is shown even if the merchant is not required on failed scan.

    What is the root cause of that problem?

    We calculate the hasErrors value here using TransactionUtils.hasMissingSmartscanFields, which checks for missing amount, date, and merchant (if the merchant is required):

    let hasErrors = false;
    if (hasReceipt) {
    receiptURIs = ReceiptUtils.getThumbnailAndImageURIs(transaction);
    hasErrors = canEdit && TransactionUtils.hasMissingSmartscanFields(transaction);
    }

    However, when showing the merchant error, we check only hasErrors (which comes from the missing amount) and the empty merchant, without checking if the merchant is required:

    <MenuItemWithTopDescription
    description={translate('common.merchant')}
    title={isEmptyMerchant ? '' : transactionMerchant}
    interactive={canEdit}
    shouldShowRightIcon={canEdit}
    titleStyle={styles.flex1}
    onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.MERCHANT))}
    brickRoadIndicator={hasErrors && isEmptyMerchant ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''}
    error={hasErrors && isEmptyMerchant ? translate('common.error.enterMerchant') : ''}
    />

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

    We should introduce another variable, e.g.:

    val isMerchantRequired: TransactionUtils.isMerchantRequired(transaction);

    And use it as well to determine whether to show the merchant error:

    <OfflineWithFeedback pendingAction={lodashGet(transaction, 'pendingFields.merchant') || lodashGet(transaction, 'pendingAction')}>
                            <MenuItemWithTopDescription
                                description={translate('common.merchant')}
                                title={isEmptyMerchant ? '' : transactionMerchant}
                                interactive={canEdit}
                                shouldShowRightIcon={canEdit}
                                titleStyle={styles.flex1}
                                onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.MERCHANT))}
                                brickRoadIndicator={hasErrors && isEmptyMerchant && isMerchantRequired ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''}
                                error={hasErrors && isEmptyMerchant && isMerchantRequired ? translate('common.error.enterMerchant') : ''}
                            />
    </OfflineWithFeedback>

    Since the "is merchant required" will be reusable now, we should move it out from TransactionUtils.areRequiredFieldsEmpty into a new function I mentioned above:

    function isMerchantRequired(transaction: Transaction): boolean {
        const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`] ?? null;
        return parentReport?.type === CONST.REPORT.TYPE.EXPENSE;
    }

    What alternative solutions did you explore? (Optional)

    Probably a preferable approach for me: we should move away from using the general hasErrors, and use field-dedicated variables, like hasAmountError, hasMerchantError, hasDateError, built using the corresponding TransactionUtils.is*Missing functions.

    Because currently, we basically persorm the same check for each field twice: first time - when calculating the hasErrors, and then – when checking each field error for RBR:

    error={hasErrors && isEmptyMerchant ? translate('common.error.enterMerchant') : ''}

    error={hasErrors && transactionDate === '' ? translate('common.error.enterDate') : ''}

    error={hasErrors && transactionAmount === 0 ? translate('common.error.enterAmount') : ''}

  12. 27 remaining items

  13. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Jan 18, 2024
  14. changed the title [-][$250] Scan - Message for Merchant requirement disappears after entering amount for failed scanning[/-] [+][HOLD for payment 2024-01-25] [$250] Scan - Message for Merchant requirement disappears after entering amount for failed scanning[/+] on Jan 18, 2024
  15. melvin-bot commented on Jan 18, 2024

    @melvin-bot

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

  16. melvin-bot commented on Jan 18, 2024

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.26-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-01-25. 🎊

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

  17. melvin-bot commented on Jan 18, 2024

    @melvin-bot

    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:

    • [@mountiny] The PR that introduced the bug has been identified. Link to the PR:
    • [@mountiny] 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:
    • [@mountiny] 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:
    • [@namhihi237 / @shubham1206agra] Determine if we should create a regression test for this bug.
    • [@namhihi237 / @shubham1206agra] 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.
    • [@NicMendonca] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  18. NicMendonca commented on Jan 29, 2024

    @NicMendonca
    Contributor

    @shubham1206agra can you accept the offer please?

  19. NicMendonca commented on Jan 29, 2024

    @NicMendonca
    Contributor

    @namhihi237 you've been paid!

  20. shubham1206agra commented on Jan 30, 2024

    @shubham1206agra
    Contributor

    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:

  21. NicMendonca commented on Jan 30, 2024

    @NicMendonca
    Contributor

    @shubham1206agra you've been paid!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions