Skip to content

[Hold #31411] [$500] Scan - None not displayed in merchant while offline & after adding amount & going online #32552

Closed

Description

@izarutskaya

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Found when executing PR: #31897

Version Number: 1.4.8-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. Open the app and log in
  2. Disable internet connection
  3. Tap FAB > Request Money > Scan
  4. Select a receipt and a user
  5. Complete the request
  6. Navigate to the transaction chat
  7. Enter the amount
  8. Enable internet connection

Expected Result:

"None" is displayed in the Merchant field while offline and after adding amount and going online, the red dot is shown

Actual Result:

"Request" is displayed in the Merchant field offline and after adding the amount and returning online, the red dot is not shown unlike in the online flow.

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

Bug6302703_1701837443776.video_2023-12-05_23-28-40.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~015c62fdfd300d1084
  • Upwork Job ID: 1732346017160351744
  • Last Price Increase: 2023-12-06

Activity

  1. added
    External
    Daily
    Bug
    on Dec 6, 2023
  2. melvin-bot commented on Dec 6, 2023

    @melvin-bot

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

  3. changed the title [-]Scan - None not displayed in merchant while offline & after adding amount & going online[/-] [+][$500] Scan - None not displayed in merchant while offline & after adding amount & going online[/+] on Dec 6, 2023
  4. melvin-bot commented on Dec 6, 2023

    @melvin-bot
  5. melvin-bot commented on Dec 6, 2023

    @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
  6. added
    Help Wanted
    on Dec 6, 2023
  7. melvin-bot commented on Dec 6, 2023

    @melvin-bot

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

  8. paultsimura commented on Dec 6, 2023

    @paultsimura
    Contributor

    Proposal

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

    Merchant is not set to (none) when creating the scan request offline. Also, the error is not shown when coming back online after modifying the request.

    What is the root cause of that problem?

    We do not set the (none) merchant value optimistically when placing the scan money request. The RBR is displayed if the value is set to (none), which is set on the API response of RequestMoney API call (which doesn't happen when online).

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

    When creating an optimistic transaction, we should check if it's a scan transaction, and if so – set "none" instead of the default "Request" in the merchant (using constants and polishing the code a bit, but the idea is understandable):

    merchant: merchant || (!!receipt?.state ? '(none)' : CONST.TRANSACTION.DEFAULT_MERCHANT),

    merchant: merchant || CONST.TRANSACTION.DEFAULT_MERCHANT,

    Note: There is another issue happening – the optimistic transaction report gets replaced when coming back online, which leads to an error if the request created online optimistically is opened when coming back online. It will be fixed in #31411 – asked and got a confirmation here. Therefore, we may want to hold this issue until that one is done.

    What alternative solutions did you explore? (Optional)

  9. bernhardoj commented on Dec 6, 2023

    @bernhardoj
    Contributor

    Proposal

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

    1. When creating a scan money request with an empty merchant while offline, the merchant field shows Request instead of (none)
    2. After updating the amount, there is no error message and RBR shown for the merchant even though it's actually empty.

    What is the root cause of that problem?

    1. When we create a scan request, we optimistically set the merchant to Request if it's empty.
      merchant: merchant || CONST.TRANSACTION.DEFAULT_MERCHANT,

    It's to fix this issue #28380 where BE response will return Request if the merchant is empty, so we align the optimistic data with the BE response. But now, the BE response return (none) if the merchant sent to the API is empty.

    1. When we update the amount (or other field), it will stop the smart scan and will show an error if there is an empty required field, such as the merchant field.
      if (Object.hasOwn(transactionChanges, 'amount') && typeof transactionChanges.amount === 'number') {
      updatedTransaction.modifiedAmount = isFromExpenseReport ? -transactionChanges.amount : transactionChanges.amount;
      shouldStopSmartscan = true;
      }

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

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

    However, as we optimistically set the merchant to Request, the error won't show.

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

    The merchant will detect (none) as an empty merchant, so my suggestion is to make sure whether it's expected that the BE now returns (none) for an empty merchant or it should be Request like in #29118.

    If it's expected that it now returns (none), we can revert #29118 and adjust the code a little bit by replacing the empty string with (none).

    -const defaultMerchant = !receipt || Object.keys(receipt).length === 0 ? CONST.TRANSACTION.DEFAULT_MERCHANT : '';
    +const defaultMerchant = !receipt || Object.keys(receipt).length === 0 ? CONST.TRANSACTION.DEFAULT_MERCHANT : CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT;
    
    merchant: merchant || defaultMerchant,
  10. trjExpensify commented on Dec 6, 2023

    @trjExpensify
    Contributor

    @mountiny given the changes you're making, is this issue going to be obsolete?

  11. mountiny commented on Dec 6, 2023

    @mountiny
    Contributor

    I am not 100% sure, this Pr is handling the manual requests only not the scan case #32222

    I think the solutions from @paultsimura and @bernhardoj are valid for this problem

  12. 23 remaining items

  13. trjExpensify commented on Jan 31, 2024

    @trjExpensify
    Contributor

    Still held, PR should be coming soon!

  14. trjExpensify commented on Feb 9, 2024

    @trjExpensify
    Contributor

    No change!

  15. trjExpensify commented on Feb 19, 2024

    @trjExpensify
    Contributor

    @fedirjh I think the PR we're held on is this, right?

  16. fedirjh commented on Feb 19, 2024

    @fedirjh
    Contributor

    @trjExpensify Yes that's right.

  17. trjExpensify commented on Feb 19, 2024

    @trjExpensify
    Contributor

    Sounds good!

  18. fedirjh commented on Feb 28, 2024

    @fedirjh
    Contributor

    @trjExpensify The PR was deployed to staging.

    "None" is displayed in the Merchant field while offline, and after adding amount and going online, the red dot is shown

    @trjExpensify For the expected result, could you please verify it ? why the red dot should be shown when we change the amount in offline mode while the request is scanning?

  19. trjExpensify commented on Mar 1, 2024

    @trjExpensify
    Contributor

    I don't think this is a valid bug anymore.

    • The merchant is blank while receipt scanning is in progress
    • When you enter an amount the receipt scanning stops
    • a merchant is a required field on a workspace, so the RBR is added and a field error shows on the merchant field
    • the amount field is populated with the value you entered and no field error appears.

    Going to close it out!

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

Metadata

Metadata

Labels

BugExternalHelp WantedWeekly

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions