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-02-07][$500] Page refresh causes manual request with a receipt to be stuck #30884

Closed
3 of 6 tasks
m-natarajan opened this issue Nov 4, 2023 · 64 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 External Added to denote the issue can be worked on by a contributor

Comments

@m-natarajan
Copy link

m-natarajan commented Nov 4, 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!


Version Number: 1.3.95-5
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: @abdel-h66
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1698081033316989

Action Performed:

  1. Open a chat
  2. Create a manual request thought the chat plus icon (not the FAB)
  3. Enter an amount and Next
  4. Click the three dots on the top, and attach a receipt
  5. Refresh the page in this step
  6. The page will go back to the first step, autofilled with the previous amount.
  7. Click next

Expected Result:

We should be able to continue to the request information page

Actual Result:

The page is stuck and keeps coming back whenever Next is clicked

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

Recording.198.mp4
Expensify.bugs.mp4
Monosnap.screencast.Oct.23.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01b422f44a99747ac7
  • Upwork Job ID: 1720802592517115904
  • Last Price Increase: 2023-12-21
  • Automatic offers:
    • DylanDylann | Contributor | 28067917
@m-natarajan m-natarajan 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 Nov 4, 2023
@melvin-bot melvin-bot bot changed the title Page refresh causes manual request with a receipt to be stuck [$500] Page refresh causes manual request with a receipt to be stuck Nov 4, 2023
Copy link

melvin-bot bot commented Nov 4, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01b422f44a99747ac7

Copy link

melvin-bot bot commented Nov 4, 2023

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

Copy link

melvin-bot bot commented Nov 4, 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 Nov 4, 2023
Copy link

melvin-bot bot commented Nov 4, 2023

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

@DylanDylann
Copy link
Contributor

DylanDylann commented Nov 4, 2023

Proposal

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

Page refresh causes manual request with a receipt to be stuck

What is the root cause of that problem?

Firstly, Let's see this issue: #28347 (similar case with scan flow)

We discussed about this problem before with scan request. But we missed a case: the manual request by adding a receipt

Note that if we upload the receipt and back to the participant page and then reload, the same bug also happens. This bug is mentioned here

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

In here

const onFailure = () => navigateToStartMoneyRequestStep(requestType, iouType, transactionID, reportID);

We should add a check if It is a manual request and the file is lost. The app will be on the confirmation page and the receipt thumbnail is removed

const onFailure = () => {
        console.log("onFailure: ", requestType)
        if (requestType === CONST.IOU.REQUEST_TYPE.MANUAL) {
            IOU.setMoneyRequestReceipt_temporaryForRefactor(transactionID, '', '');
            return 
        }
        navigateToStartMoneyRequestStep(requestType, iouType, transactionID, reportID)
    }

With the big refactor on the request flow, navigateToStartStepIfScanFileCannotBeRead also be used in the participant page so this change also fix the bug on the participant page

This is result

sol.mp4

What alternative solutions did you explore? (Optional)

In here

const onFailure = () => navigateToStartMoneyRequestStep(requestType, iouType, transactionID, reportID);

We should add a check if It is a manual request and the file is lost. The app will redirect to the uploading screen

const onFailure = () => {
        console.log("onFailure: ", requestType)
        if (requestType === CONST.IOU.REQUEST_TYPE.MANUAL) {
            Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()));
            return 
        }
        navigateToStartMoneyRequestStep(requestType, iouType, transactionID, reportID)
    }

@s-alves10
Copy link
Contributor

Proposal

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

After adding a receipt to the manual request, page refresh causes manual request to be stuck

What is the root cause of that problem?

When we adding a receipt to the manual request, we create blob URL and set it to the iou

const filePath = URL.createObjectURL(file);
IOU.setMoneyRequestReceipt(filePath, file.name);

const filePath = URL.createObjectURL(imageFile);
IOU.setMoneyRequestReceipt(filePath, imageFile.name);

But this object URL is only valid for the current session and will be revoked once the page is refreshed. So when navigating to the confirmation page, file would be null and it'll be redirected to the manual request page or previous page.

FileUtils.readFileAsync(props.iou.receiptPath, props.iou.receiptFilename).then((file) => {
if (!file) {
Navigation.goBack(ROUTES.MONEY_REQUEST.getRoute(iouType, reportID));
} else {

This is the root cause

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

I don't think we need to go back to the manual request page when object URL is not valid.
I suggest to reset the receipt in this case

Update the above code to

        FileUtils.readFileAsync(props.iou.receiptPath, props.iou.receiptFilename).then((file) => {
            if (!file) {
                IOU.setMoneyRequestReceipt('', '');
            } else {
Result
30884.mp4

What alternative solutions did you explore? (Optional)

@DylanDylann
Copy link
Contributor

@s-alves10 Your proposal is the same as my alternative solution 😄 (same interesting idea)

@abdel-h66
Copy link
Contributor

abdel-h66 commented Nov 4, 2023

I actually reported this one and worked on a solution that I shared on Slack. Not sure why @m-natarajan didn't include it :) could you double-check again please :), and please check the Reported GitHub ID. that's not me it should be @abdel-h66

@m-natarajan
Copy link
Author

Proposal by @abdel-h66

Proposal

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

When a receipt is added to a Manual request, refreshing the page will cause the manual request process to be stuck.

What is the root cause of that problem?

  • When a receipt is added to a Manual request, we save it in a local file (blob)
  • This allows the user to move back and fort between the MoneyRequestAmountForm and MoneyRequestConfirmPage and keep the receipt attached to the IOU request to be viewed.
  • When the page is refreshed, the IOU will still have the local file data as receipt, but this file is no longer readable.
  • When we try to read this file here
    FileUtils.readFileAsync(props.iou.receiptPath, props.iou.receiptFilename).then((file) => {
  • We will get an error and the Navigation will instantly take us back to the MONEY_REQUEST page.
  • The issue will persist as long as there is an unreadable file in the IOU object

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

→ In the useEffect here that checks for the existence of the receipt (this logic was added to fix this issue)
→ we check If the receipt is a local file using

const isLocalReceiptFile = receiptPath.startsWith('file://') || receiptPath.startsWith('blob:');

→ if this file could not be read, then we reset the money request receipt with

IOU.setMoneyRequestReceipt('', '')

→ the final solution will be something like this

            if (!file) {
                if(isLocalReceiptFile) {
                    IOU.setMoneyRequestReceipt('', '')
                    return;
                }
                Navigation.goBack(ROUTES.MONEY_REQUEST.getRoute(iouType.current, reportID.current));
            } else {
                const receipt = file;
                receipt.state = file && isManualRequestDM ? CONST.IOU.RECEIPT_STATE.OPEN : CONST.IOU.RECEIPT_STATE.SCANREADY;
                setReceiptFile(receipt);
            }

What alternative solutions did you explore? (Optional)

N/A

@lschurr
Copy link
Contributor

lschurr commented Nov 6, 2023

@eVoloshchak could you take a look at the discussion on this GH?

@lschurr
Copy link
Contributor

lschurr commented Nov 9, 2023

Bump @eVoloshchak

@melvin-bot melvin-bot bot removed the Overdue label Nov 9, 2023
Copy link

melvin-bot bot commented Nov 11, 2023

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

@melvin-bot melvin-bot bot added the Overdue label Nov 11, 2023
@lschurr
Copy link
Contributor

lschurr commented Nov 11, 2023

@melvin-bot melvin-bot bot removed the Overdue label Nov 11, 2023
@eVoloshchak
Copy link
Contributor

This has been resolved in #30832

@lschurr
Copy link
Contributor

lschurr commented Nov 13, 2023

Ok, great! Closing this one out.

@lschurr
Copy link
Contributor

lschurr commented Jan 19, 2024

Could you weigh in here @eVoloshchak?

@melvin-bot melvin-bot bot added the Overdue label Jan 22, 2024
@lschurr
Copy link
Contributor

lschurr commented Jan 22, 2024

Any update on the regression here @DylanDylann @eVoloshchak?

@melvin-bot melvin-bot bot removed the Overdue label Jan 22, 2024
@eVoloshchak
Copy link
Contributor

@DylanDylann, let's proceed with the first option here, the second would require duplicating the onFailure logic
Could you spin-up the PR?

@DylanDylann
Copy link
Contributor

@eVoloshchak this function is written by Typescript but currently, IOU.js file don't support typescript. I suggest that we should hold this until #24926 (migrate IOU.js to typescript) is done.

cc @cristipaval

@eVoloshchak
Copy link
Contributor

@DylanDylann, let's just revert the function back to vanilla JS. Hold on #24926 will be removed on Jan 26, but it's a huge file, and a migration to TS will take time. Let's get rid of this warning, the function is pretty small, it won't be hard to convert it to TS again

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jan 25, 2024
@DylanDylann
Copy link
Contributor

@eVoloshchak The PR is ready for review: #35127

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Jan 31, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-01-18] [$500] Page refresh causes manual request with a receipt to be stuck [HOLD for payment 2024-02-07] [HOLD for payment 2024-01-18] [$500] Page refresh causes manual request with a receipt to be stuck Jan 31, 2024
Copy link

melvin-bot bot commented Jan 31, 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 Jan 31, 2024
Copy link

melvin-bot bot commented Jan 31, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.33-5 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-02-07. 🎊

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

Copy link

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

@lschurr lschurr changed the title [HOLD for payment 2024-02-07] [HOLD for payment 2024-01-18] [$500] Page refresh causes manual request with a receipt to be stuck [HOLD for payment 2024-02-07][$500] Page refresh causes manual request with a receipt to be stuck Jan 31, 2024
@lschurr
Copy link
Contributor

lschurr commented Feb 4, 2024

@eVoloshchak @DylanDylann - could you work through the new checklist for this one?

@eVoloshchak
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: there isn't a PR that has caused this, this is an edge case that was missed during the initial implementation
  • 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: we already have the necessary item in the reviewer checklist: " I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)"
  • Determine if we should create a regression test for this bug.
    Is it easy to test for this bug? Yes
    Is the bug related to an important user flow? Yes
    Is it an impactful bug? It's an edge case, but it's an edge case that completely crashes the app, I'd call that impactful

Regression Test Proposal

  1. Open a chat
  2. Create a manual request thought the chat plus icon (not the FAB)
  3. Enter an amount and click Next
  4. Click the three dots on the top, and attach a receipt
  5. Refresh the page
  6. The page should go back to the first step, autofilled with the previous amount.
  7. Click next
  8. Verify that you're able to continue to the request information page

Do we agree 👍 or 👎

@eVoloshchak
Copy link
Contributor

This is ready for payment, @lschurr, could you post the payment summary please?
Noting this has caused a regression, the amount should be $250

@lschurr
Copy link
Contributor

lschurr commented Feb 7, 2024

Yep, I will review and post payment summary today.

@lschurr lschurr added Daily KSv2 and removed Weekly KSv2 labels Feb 7, 2024
@lschurr
Copy link
Contributor

lschurr commented Feb 7, 2024

Payment summary:

@lschurr
Copy link
Contributor

lschurr commented Feb 7, 2024

Added new QA test request: https://github.com/Expensify/Expensify/issues/367651

Closing out this issue.

@lschurr lschurr closed this as completed Feb 7, 2024
@JmillsExpensify
Copy link

$250 approved for @eVoloshchak based on summary above.

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 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

10 participants