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 #27168] [$1000] Payments - App crashes when navigating to enable payments page before logging in #26021

Closed
2 of 6 tasks
lanitochka17 opened this issue Aug 27, 2023 · 39 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 Monthly KSv2 Reviewing Has a PR in review

Comments

@lanitochka17
Copy link

lanitochka17 commented Aug 27, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Log out of your account
  2. Go to `/enable-payments
  3. Login with another account

Expected Result:

There should be no crash and it should show the page

Actual Result:

The app crashes

Workaround:

Unknown

Platforms:

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

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

Version Number: 1.3.57-5

Reproducible in staging?: Yes

Reproducible in production?: Yes

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

Screen.Recording.2023-08-18.at.9.01.47.PM.mov
Recording.3000.mp4

Expensify/Expensify Issue URL:

Issue reported by: @esh-g

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1692372864188139

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0185374146bc15359c
  • Upwork Job ID: 1696179031964413952
  • Last Price Increase: 2023-08-28
  • Automatic offers:
    • cubuspl42 | Reviewer | 26485367
    • hoangzinh | Contributor | 26485370
    • esh-g | Reporter | 26485371
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 27, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 27, 2023

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

@melvin-bot
Copy link

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

@hungvu193
Copy link
Contributor

hungvu193 commented Aug 27, 2023

Proposal

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

Payments - App crashes when navigating to enable payments page before logging in

What is the root cause of that problem?

Problem came from this function when we tried to get the indexOf from undefined value.

defaultValue={PersonalDetails.extractFirstAndLastNameFromAvailableDetails(currentUserPersonalDetails).firstName}

const firstSpaceIndex = displayName.indexOf(' ');

Screen Shot 2023-08-27 at 08 45 22

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

We should add loading check inside our AdditionalDetailsStep to prevent this crash:

// personalDetailsList from ONYXKEYS.PERSONAL_DETAILS_LIST
if (!_.isPersonalDetailsReady(personalDetailsList) || _.isEmpty(currentPersonalDetails)) {
return <FullscreenLoading />

}
function isPersonalDetailsReady(personalDetails) {
    return !_.isEmpty(personalDetails) && _.some(_.keys(personalDetails), (key) => personalDetails[key].accountID);
}

Also adding a defaultValue for displayName as empty string inside extractFirstAndLastNameFromAvailableDetails function.

Other screens that used the currentPersonalDetails can also face this issue, we can apply this fix for those screens too.

What alternative solutions did you explore? (Optional)

N/A

@pradeepmdk
Copy link
Contributor

pradeepmdk commented Aug 27, 2023

Proposal

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

App crashes when navigating to the enable payments page before logging

What is the root cause of that problem?

when login currentUserPersonalDetails having only accountID remaining is not set

Why means after signin it will fetch personaldeatils information from back end and set to onyx and before sign we are trying to reach /enabled-payments page so after signin it will directly render to that page.

Screenshot 2023-08-27 at 7 42 01 AM

before loading currentUserPersonalDetails fully page tries to render
const currentUserPersonalDetails = useMemo(() => ({...props.personalDetails[accountID], accountID}), [props.personalDetails, accountID]);

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

  1. We should remove accountID here and check the the empty of currentUserPersonalDetails in the additionalDetailsSteps page
    const currentUserPersonalDetails = useMemo(() => ({...props.personalDetails[accountID], accountID}), [props.personalDetails, accountID]);
_.isEmpty(currentPersonalDetails)) {
return <FullscreenLoading />

}
  1. we should declare all the props empty in WithCurrentUserPersonalDetails
    Or we can declare empty in request param
    extractFirstAndLastNameFromAvailableDetails({login, displayName='', firstName='', lastName=''})

@hoangzinh
Copy link
Contributor

hoangzinh commented Aug 27, 2023

Proposal

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

Payments - App crashes when navigating to enable payments page before logging in

What is the root cause of that problem?

  • The error come from this line
    defaultValue={PersonalDetails.extractFirstAndLastNameFromAvailableDetails(currentUserPersonalDetails).firstName}

    The currentUserPersonalDetails is null so it raises error when we call function extractFirstAndLastNameFromAvailableDetails
Screenshot 2023-08-27 at 15 37 10
  • The root cause is because after login, the OpenApp API is not completed yet, so the personalDetailsList is not ready yet => We couldn't get the currentUserPersonalDetails in this line, so it will be null:
    const currentUserPersonalDetails = useMemo(() => ({...props.personalDetails[accountID], accountID}), [props.personalDetails, accountID]);

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

In the EnablePaymentsPage component, we should check if the Onyx key ONYXKEYS.IS_LOADING_REPORT_DATA is true, we should display loading page in this line

if (_.isEmpty(this.props.userWallet)) {
return <FullScreenLoadingIndicator />;
}

So it only renders child components whenever the OpenApp data is ready.

@NicMendonca NicMendonca added the External Added to denote the issue can be worked on by a contributor label Aug 28, 2023
@melvin-bot melvin-bot bot changed the title Payments - App crashes when navigating to enable payments page before logging in [$1000] Payments - App crashes when navigating to enable payments page before logging in Aug 28, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 28, 2023

Job added to Upwork: https://www.upwork.com/jobs/~0185374146bc15359c

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

melvin-bot bot commented Aug 28, 2023

Current assignee @NicMendonca is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Aug 28, 2023

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

@melvin-bot melvin-bot bot added the Overdue label Aug 29, 2023
@NicMendonca
Copy link
Contributor

@cubuspl42 some proposals for you to review here! ^

@melvin-bot melvin-bot bot removed the Overdue label Aug 29, 2023
@cubuspl42
Copy link
Contributor

@NicMendonca This is next on my list! I'll start reviewing them tomorrow morning, i.e. in ~10 hours

@cubuspl42
Copy link
Contributor

@hungvu193 While the solution might work on the technical level, your root cause analysis is a bit shallow. You focused on what's happening on the programming language level, not on what's happening from the broader perspective and why.

@hoangzinh Your root cause analysis sounds reasonable. Could you elaborate a bit on the solution part? As I understand it, the missing (not-yet-loaded) data is the current user personal details. That doesn't sound like a part of the "report data", what am I missing? Is the semantics of IS_LOADING_REPORT_DATA key different than what could be concluded from the name?

@hungvu193
Copy link
Contributor

@hungvu193 While the solution might work on the technical level, your root cause analysis is a bit shallow. You focused on what's happening on the programming language level, not on what's happening from the broader perspective and why.

I proposed using isLoadingReportData from my first proposal, but I feel that's more meaning full to use isPersonalDetailsReady, because it's better to avoid the weird dependency when the page doesn't appear to actually require anything about the report.

@hoangzinh
Copy link
Contributor

hoangzinh commented Aug 30, 2023

@cubuspl42 Yeah, the Onyx key name IS_LOADING_REPORT_DATA is quite of confusing. Is it the flag to check whether the OpenApp API is finish or not. The OpenApp API includes personalDetailsList
Screenshot 2023-08-30 at 17 51 06

@hoangzinh
Copy link
Contributor

hoangzinh commented Aug 30, 2023

I think we should check above flag IS_LOADING_REPORT_DATA because it's a correct signal to check whether the API to fetch personalDetailsList data is completed. Moreover, later on, if the page depends on other needed data in the API above, we can cover it by the single flag IS_LOADING_REPORT_DATA as well.

@cubuspl42
Copy link
Contributor

I say we go with the @hoangzinh proposal. The root cause analysis is the clearest and the proposed solution sounds reasonable to me.

C+ reviewed 🎀 👀 🎀

@melvin-bot
Copy link

melvin-bot bot commented Aug 30, 2023

Triggered auto assignment to @robertjchen, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@robertjchen
Copy link
Contributor

Thanks, reviewing this now

@robertjchen
Copy link
Contributor

Agreed with @hoangzinh 's analysis and approach 👍

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 4, 2023
@hoangzinh
Copy link
Contributor

Somehow in latest main branch, after sign in, the App could not redirect to the /enable-payments. Is it a bug or there is something change recently? I checked the code and it seems we only support open a chat report after sign in/sign up atm

App/src/Expensify.js

Lines 170 to 173 in 8150ce0

Linking.getInitialURL().then((url) => {
DemoActions.runDemoByURL(url);
Report.openReportFromDeepLink(url, isAuthenticated);
});

cc @cubuspl42 @robertjchen

@cubuspl42
Copy link
Contributor

I know that there were some last minute changes to navigation before the conference. The "demos" mentioned in your snippet are supposed to be gone soon, if I understand this right.

@hoangzinh
Copy link
Contributor

I worry that we can't reproduce this bug anymore. cc @esh-g if you still reproduce this bug.

@cubuspl42
Copy link
Contributor

I also asked on Slack whether the change is intentional

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 10, 2023
@cubuspl42
Copy link
Contributor

Could we please hold this on this bug? I know that the PR is already created, but it's not our fault that that bug was introduced, and it makes difficult to properly verify the fix for our issue.

Unfortunately, there's still no GH for the mentioned thing, so we can "[HOLD Broken deeplinks]" or something like that.

@cubuspl42
Copy link
Contributor

This is the GH issue: #27168

@cubuspl42
Copy link
Contributor

@NicMendonca Please add a hold on #27168

@NicMendonca NicMendonca changed the title [$1000] Payments - App crashes when navigating to enable payments page before logging in [Hold for #27168] [$1000] Payments - App crashes when navigating to enable payments page before logging in Sep 20, 2023
@melvin-bot melvin-bot bot removed the Weekly KSv2 label Oct 9, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 9, 2023

This issue has not been updated in over 15 days. @robertjchen, @cubuspl42, @hoangzinh, @NicMendonca eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@melvin-bot melvin-bot bot added the Monthly KSv2 label Oct 9, 2023
@cubuspl42
Copy link
Contributor

Still on hold

@robertjchen
Copy link
Contributor

still on hold

@hoangzinh
Copy link
Contributor

@cubuspl42 @robertjchen it looks like it's fixed somewhere. I couldn't reproduce this issue in the latest main.

Screen.Recording.2023-11-30.at.23.57.10.mov

@cubuspl42
Copy link
Contributor

Conclusion: if you hold for long enough, the issue fixes itself 😅

@hoangzinh
Copy link
Contributor

So I think the next step should be payment, and then closing this issue 🤔

@cubuspl42
Copy link
Contributor

cubuspl42 commented Dec 4, 2023

It's a delicate topic, but there probably will be no payment. Unless it's a very special case (which this one isn't), payments are done for merged PRs. I'm sorry about this, but this is one of the inherent risks associated with our process.

@hoangzinh
Copy link
Contributor

hoangzinh commented Dec 4, 2023

Ah @cubuspl42 fyi, this case is the same as step 19. in Updated process section of https://docs.google.com/document/d/1BvohU05MTaHnjOD_vwJv_aqDAirv-ChkyRnKCAvOVyQ

@hoangzinh
Copy link
Contributor

hoangzinh commented Jan 2, 2024

cc @NicMendonca can you help process payment here then we can close this issue? ^ Thanks

@cubuspl42
Copy link
Contributor

It seems you're right

@NicMendonca
Copy link
Contributor

everyone's been paid!

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 Monthly KSv2 Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

7 participants