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 #31411] [$500] Scan - None not displayed in merchant while offline & after adding amount & going online #32552

Closed
5 of 6 tasks
izarutskaya opened this issue Dec 6, 2023 · 24 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Weekly KSv2

Comments

@izarutskaya
Copy link

izarutskaya commented Dec 6, 2023

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
@izarutskaya izarutskaya added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 6, 2023
Copy link

melvin-bot bot commented Dec 6, 2023

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

@melvin-bot melvin-bot bot 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 Dec 6, 2023
Copy link

melvin-bot bot commented Dec 6, 2023

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

Copy link

melvin-bot bot commented Dec 6, 2023

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 6, 2023
Copy link

melvin-bot bot commented Dec 6, 2023

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

@paultsimura
Copy link
Contributor

paultsimura commented Dec 6, 2023

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)

@bernhardoj
Copy link
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,

@trjExpensify
Copy link
Contributor

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

@mountiny
Copy link
Contributor

mountiny commented Dec 6, 2023

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

@cead22
Copy link
Contributor

cead22 commented Dec 6, 2023

But I suppose it will be fixed in #31411 – asked to confirm here. If it's true, we may want to hold this issue until that one is done.

I replied in the linked issue, but sharing here for visibility: we're in the process of updating the RequestMoney end point to accept and use the new parameters transactionThreadReportID and createdReportActionIDForThread.

If this is the only cause of the issue, I suggest adding a hold until that's done

@paultsimura
Copy link
Contributor

If this is the only cause of the issue

It's not the root cause, but it's causing some trouble with testing the offline-online transition. The issue will still require fixing and the proposals are relevant.

@trjExpensify
Copy link
Contributor

Cool, so do we want to hold and ask for proposals after that or continue with soliciting proposals in the meantime and then hold the imp on that?

@melvin-bot melvin-bot bot added the Overdue label Dec 8, 2023
@mountiny
Copy link
Contributor

mountiny commented Dec 8, 2023

I think we can hold for the changes linked above and then check if the issue is still the same and choose proposals.

@trjExpensify trjExpensify changed the title [$500] Scan - None not displayed in merchant while offline & after adding amount & going online [Hold #31411] [$500] Scan - None not displayed in merchant while offline & after adding amount & going online Dec 11, 2023
@trjExpensify
Copy link
Contributor

Cool, done!

@melvin-bot melvin-bot bot removed the Overdue label Dec 11, 2023
@trjExpensify trjExpensify added Weekly KSv2 and removed Daily KSv2 labels Dec 11, 2023
@melvin-bot melvin-bot bot added the Overdue label Dec 19, 2023
@trjExpensify
Copy link
Contributor

Still held.

@trjExpensify
Copy link
Contributor

Still held on #31411

@melvin-bot melvin-bot bot removed the Overdue label Jan 3, 2024
@melvin-bot melvin-bot bot added the Overdue label Jan 11, 2024
@trjExpensify
Copy link
Contributor

No change, Melvy boy!

@melvin-bot melvin-bot bot removed the Overdue label Jan 12, 2024
@melvin-bot melvin-bot bot added the Overdue label Jan 22, 2024
@fedirjh
Copy link
Contributor

fedirjh commented Jan 22, 2024

Still held on #31411.

@melvin-bot melvin-bot bot removed the Overdue label Jan 22, 2024
@melvin-bot melvin-bot bot added the Overdue label Jan 30, 2024
@trjExpensify
Copy link
Contributor

Still held, PR should be coming soon!

@melvin-bot melvin-bot bot removed the Overdue label Jan 31, 2024
@melvin-bot melvin-bot bot added the Overdue label Feb 8, 2024
@trjExpensify
Copy link
Contributor

No change!

@melvin-bot melvin-bot bot removed the Overdue label Feb 9, 2024
@melvin-bot melvin-bot bot added the Overdue label Feb 19, 2024
@trjExpensify
Copy link
Contributor

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

@melvin-bot melvin-bot bot removed the Overdue label Feb 19, 2024
@fedirjh
Copy link
Contributor

fedirjh commented Feb 19, 2024

@trjExpensify Yes that's right.

@trjExpensify
Copy link
Contributor

Sounds good!

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

fedirjh commented Feb 28, 2024

@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?

@melvin-bot melvin-bot bot removed the Overdue label Feb 28, 2024
@trjExpensify
Copy link
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
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Weekly KSv2
Projects
None yet
Development

No branches or pull requests

7 participants