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 2023-09-08] Web - App Crashes when reloading after editing the Merchant #26181

Closed
1 of 6 tasks
kbecciv opened this issue Aug 29, 2023 · 44 comments
Closed
1 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Engineering Weekly KSv2

Comments

@kbecciv
Copy link

kbecciv commented Aug 29, 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!


Action Performed:

  1. Request money from user A
  2. Go the report
  3. Click on the Merchant to edit
  4. Clear the field and click on Save
    Notice 'removed the merchant (previously "Request")' message appears
  5. Refresh the page

Expected Result:

The app does not crash

Actual Result:

App crashes

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.58.0
Reproducible in staging?: y
Reproducible in production?: n
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
Notes/Photos/Videos: Any additional supporting documentation

T131.Appchrash-1.mp4
Recording.4065.mp4

Expensify/Expensify Issue URL:
Issue reported by: @daveSeife
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1693277798912359

View all open jobs on GitHub

@kbecciv kbecciv added the DeployBlockerCash This issue or pull request should block deployment label Aug 29, 2023
@OSBotify
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open StagingDeployCash deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@melvin-bot
Copy link

melvin-bot bot commented Aug 29, 2023

Triggered auto assignment to @MariaHCD (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@mountiny
Copy link
Contributor

Merchant cannot be empty thats backend restriction, we probably need to add a validation here

@Pujan92
Copy link
Contributor

Pujan92 commented Aug 29, 2023

Proposal

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

Not validating the merchant field to be required(not reproducing crash on the dev env)

What is the root cause of that problem?

We don't have any validation to restrict empty value for the merchant.

Reason for a crash: When we refresh the money request report we receive incorrect structure by ReconnectApi call for reportActions which leads to the transaction undefined and accessing fields of undefined crashes the app.

<OfflineWithFeedback pendingAction={lodashGet(transaction, 'pendingFields.amount') || lodashGet(transaction, 'pendingAction')}>

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

Add validate function and pass it to the the Form by setting the merchant as a required field.

<TextInput
inputID="merchant"
name="merchant"

<TextInput
inputID="moneyRequestMerchant"
name="moneyRequestMerchant"

const validate = (values) => {
        const requiredFields = ['merchant'];
        const errors = ValidationUtils.getFieldRequiredErrors(values, requiredFields);
        return errors;
    }

Same needs to be done for MoneyRequestMerchantPage component by using the field name moneyRequestMerchant.

Provide the default value in the lodashGet pendingFields.fieldname for pendingAction prop which we are passing to OfflineWithFeedback in the MoneyRequestView component. 1, 2, 3, 4

@MariaHCD
Copy link
Contributor

cc: @koko57 Please let us know what you find, thanks!

@melvin-bot
Copy link

melvin-bot bot commented Aug 29, 2023

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@koko57
Copy link
Contributor

koko57 commented Aug 29, 2023

@MariaHCD I couldn't reproduce it locally, I managed to reproduce it on staging so it's hard for me to tell for now what the exact RC is. I think that if we don't want to change the merchant to the empty string, the solution @Pujan92 proposes should work here

@Pujan92
Copy link
Contributor

Pujan92 commented Aug 29, 2023

I am able to reproduce the crash locally also due to incorrect orders bcoz whenever we refresh the money request report we won't get pendingFields in the api onyx response which causes the issue(accessing undefined of pendingFields).

@MariaHCD
Copy link
Contributor

That makes sense, thanks @Pujan92.

One thing about your proposal:

Reason for a crash might be: Conditions are in the wrong order for all the fields here. First, we need to check for pendingAction availability in the transaction and then check for specific child fields.

Do you mean we first need to check for pendingFields in the transaction before trying to fetch any child fields?

@Pujan92
Copy link
Contributor

Pujan92 commented Aug 29, 2023

Yes @MariaHCD

Sorry, I made a mistake in thinking. We need to provide a default value for specific pendingFields considering the above reason bcoz we need to greyed out in any condition. I will update my proposal.

- {lodashGet(transaction, 'pendingFields.amount') || lodashGet(transaction, 'pendingAction')}
+ {lodashGet(transaction, 'pendingFields.amount', null) || lodashGet(transaction, 'pendingAction')}

@MariaHCD
Copy link
Contributor

Okay, I was finally able to reproduce the issue on staging and saw the console error:

Screenshot 2023-08-29 at 5 13 51 PM

Screen.Recording.2023-08-29.at.5.13.25.PM.mov

@koko57
Copy link
Contributor

koko57 commented Aug 29, 2023

looks like it doesn't see parentReportAction here

@Pujan92
Copy link
Contributor

Pujan92 commented Aug 29, 2023

Something fishy seems to be here, after a moment transactionID becomes 0(on refresh the report)

transaction: {
key: ({report}) => {
const parentReportAction = ReportActionsUtils.getParentReportAction(report);
const transactionID = lodashGet(parentReportAction, ['originalMessage', 'IOUTransactionID'], 0);
return `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`;
},

@pradeepmdk
Copy link
Contributor

@koko57 looks like same #26204

@Pujan92
Copy link
Contributor

Pujan92 commented Aug 29, 2023

I think reconnetApp api returns reportActions in the wrong structure. Needs to be an object but receiving array.

Screenshot 2023-08-29 at 19 43 57

That leads allReportActions to contain some incorrect structure entries which cause the transactionID to be 0. With that required transaction will be undefined and we try to access props on it which eventually crashes the app.

Screenshot 2023-08-29 at 19 47 42

@Pujan92
Copy link
Contributor

Pujan92 commented Aug 29, 2023

@MariaHCD @koko57 I think we do need to correct the structure in the BE for ReconnectApp api.

@parasharrajat
Copy link
Member

I can not reproduce this issue on the main. I also think that merchant is removable otherwise why would we show removed?
Screenshot 2023-08-29 at 7 55 09 PM

@koko57
Copy link
Contributor

koko57 commented Aug 29, 2023

@parasharrajat I could reproduce it locally on main when I switched to using staging server

@koko57
Copy link
Contributor

koko57 commented Aug 29, 2023

and yeah, I agree with @Pujan92 that it should be checked on the BE as it happens not only for removing the merchant but also when editing other fields

@Pujan92
Copy link
Contributor

Pujan92 commented Aug 29, 2023

I can not reproduce this issue on the main. I also think that merchant is removable otherwise why would we show removed?

Even if we try to Save by clearing the input, it passes the previousValue(not the empty value) and returns some error message in response(Call to a member function getDisplayInformation() on null).

function getMerchant(transaction) {
return lodashGet(transaction, 'modifiedMerchant', null) || lodashGet(transaction, 'merchant', '');
}

I think we are showing based on the optimistic onyx data.

Screen.Recording.2023-08-29.at.20.10.33.mov

@MariaHCD
Copy link
Contributor

I think reconnetApp api returns reportActions in the wrong structure. Needs to be an object but receiving array.

👀 Interesting, looking if something changed on the backend.

Screenshot 2023-08-29 at 6 55 34 PM

@MariaHCD
Copy link
Contributor

From this other deploy blocker: #26204

We're reverting this PR: #25675

@mountiny mountiny added Hourly KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 31, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 31, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 31, 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

@mountiny mountiny added Daily KSv2 and removed Hourly KSv2 labels Aug 31, 2023
@mountiny
Copy link
Contributor

@daveSeife Yes

$250

@mountiny mountiny reopened this Aug 31, 2023
@daveSeife
Copy link

@mountiny Okay. Thank you!

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Aug 31, 2023
@mountiny
Copy link
Contributor

Created a PR which will not allow empty merchants

@trjExpensify
Copy link
Contributor

Cool, so confirming after that PR is merged we'll pay the reporting bonus of $250 for this issue only?

@mountiny
Copy link
Contributor

@trjExpensify I think we can already pay out the reporting bonus $250, the crash is fixed now

@trjExpensify
Copy link
Contributor

Okay, perfect. @daveSeife I've sent you an offer.

@daveSeife
Copy link

@trjExpensify Accepted the offer. Thank You!

@trjExpensify
Copy link
Contributor

Perfect, paid!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Sep 1, 2023
@melvin-bot melvin-bot bot changed the title Web - App Crashes when reloading after editing the Merchant [HOLD for payment 2023-09-08] Web - App Crashes when reloading after editing the Merchant Sep 1, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Sep 1, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 1, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 1, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.61-3 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 2023-09-08. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

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

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Sep 1, 2023

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:

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. Engineering Weekly KSv2
Projects
None yet
Development

No branches or pull requests