Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.36k stars 2.78k forks source link

[HOLD for payment 2023-10-23] [HOLD for payment 2023-10-23] [HOLD for payment 2023-10-20] [HOLD for payment 2023-10-20] [$500] iOS native - App crashes when going back on a Manual request #29114

Closed trjExpensify closed 11 months ago

trjExpensify commented 11 months ago

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: v1.3.79-3 Reproducible in staging?: Y Reproducible in production?: 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: @MitchExpensify Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1696874025934959

Action Performed:

  1. "+"
  2. "Request money"
  3. Enter manual amount
  4. "Next"
  5. Click a contact (Do not "split")
  6. "<" Go back in the header beside "Manual"
  7. "<" Go back in the header beside "Split"
  8. "Next"

Expected Result:

App doesn't crash

Actual Result:

App crashes

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

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

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native https://github.com/Expensify/App/assets/16232057/f6af03ca-662c-4206-97ab-e14f25d2a259
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01426d1c07ab30e760
  • Upwork Job ID: 1711444561430691840
  • Last Price Increase: 2023-10-09
  • Automatic offers:
    • aimane-chnaif | Reviewer | 27141426
    • hungvu193 | Contributor | 27141428
melvin-bot[bot] commented 11 months ago

Current assignee @trjExpensify is eligible for the Bug assigner, not assigning anyone new.

melvin-bot[bot] commented 11 months ago

Bug0 Triage Checklist (Main S/O)

melvin-bot[bot] commented 11 months ago

Job added to Upwork: https://www.upwork.com/jobs/~01426d1c07ab30e760

melvin-bot[bot] commented 11 months ago

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

yh-0218 commented 11 months ago

Proposal

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

App crashes when going back on a Manual request

What is the root cause of that problem?

This error happen on all devices, not only native mobiles. On native mobiles, app will be crashed. On chrome, only console error. The root cause of this error is same screen is appeared when click Next Button. When click Next Button, we must move to Split screen from Manual Amount Input Screen

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

https://github.com/Expensify/App/blob/8d42ad3221927f5bf0e83b6d0e8c90038d03f4e5/src/libs/actions/IOU.js#L2274-L2276 This function reset all request info and go to input screen again. We need to call secondResetMoneyRequestInfo instead of resetMoneyRequestInfo

function secondResetMoneyRequestInfo(id = '') {
    Onyx.merge(ONYXKEYS.IOU, {
        id,
        billable: null,
    });
}

Result

https://github.com/Expensify/App/assets/65789015/6735714d-f94c-49e1-9c6d-86023e3add53

https://github.com/Expensify/App/assets/65789015/0d093de3-2d25-4d9f-adfc-5a3e14de7616

What alternative solutions did you explore? (Optional)

Vadym-33 commented 11 months ago

Proposal

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

App crashes when going back on a Manual request

What is the root cause of that problem?

https://github.com/Expensify/App/blob/8d42ad3221927f5bf0e83b6d0e8c90038d03f4e5/src/components/OptionsSelector/BaseOptionsSelector.js#L73-L75 Because of calling focus of null.

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

We can add check logic there and this works very well on my side.

setTimeout(() => {
        if (!this.textInput) {
                return;
        }
         this.textInput.focus();
 }, CONST.ANIMATED_TRANSITION);

What alternative solutions did you explore? (Optional)

mountiny commented 11 months ago

@aimane-chnaif lets prioritize this one as its important flow in coming 2 weeks. thanks!

mkhutornyi commented 11 months ago

Proposal

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

There are 2 issues here

As first bug is dupe of https://github.com/Expensify/App/issues/28129, I will provide root cause & solution only for 2nd bug here

What is the root cause of that problem?

Participants selector screen uses BaseOptionsSelector component. It uses setTimeout to autofocus input. But if component is unmounted quickly before 300ms, this.textInput becomes undefined and it tries to call undefined.focus() which makes crash. This happens because there's no clearTimeout call on component unmount. https://github.com/Expensify/App/blob/d916effd3ffb2f29adcd3cfad1e314f210a23efa/src/components/OptionsSelector/BaseOptionsSelector.js#L73-L76

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

We already have clear logic here https://github.com/Expensify/App/blob/d916effd3ffb2f29adcd3cfad1e314f210a23efa/src/components/OptionsSelector/BaseOptionsSelector.js#L136-L139

this.focusTimeout definition was somehow missing so we can add it back:

     this.focusTimeout = setTimeout(() => { 
         this.textInput.focus(); 
     }, CONST.ANIMATED_TRANSITION)
aimane-chnaif commented 11 months ago

I can confirm that navigation bug was unintentionally fixed in #27936. So we can just fix crash here. @mkhutornyi's proposal looks good to me. πŸŽ€ πŸ‘€ πŸŽ€ C+ reviewed

melvin-bot[bot] commented 11 months ago

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

yh-0218 commented 11 months ago

@aimane-chnaif I think that this crash will not happened if that navigation is fixed.

aimane-chnaif commented 11 months ago

@yh-0218 I faced this many times on the pages where options list is used. We should fix that bug

Here's another reproducible step: click Search icon and Esc key at the same time

https://github.com/Expensify/App/assets/96077027/99ef90cc-5a6e-4ae7-9915-ce1464ea414e

hungvu193 commented 11 months ago

This is dupe of: https://github.com/Expensify/App/issues/28318

cc @fedirjh

aimane-chnaif commented 11 months ago

@hungvu193 no, it's different bug

hungvu193 commented 11 months ago

Actually both of it crashed because of the timeout wasn't cleared. I also pointed it out in comment here: https://github.com/Expensify/App/issues/28318#issuecomment-1737597028

aimane-chnaif commented 11 months ago

Seems like the main purpose of that GH is different from this one - https://github.com/Expensify/App/issues/28318#issuecomment-1744929678 Also what @fedirjh found is different crash - https://github.com/Expensify/App/issues/28318#issuecomment-1752661825

hungvu193 commented 11 months ago

It was first created to resolve the console error (which because of the timeout), however while discussing it, @iwiznia pointed out that, we also need to display the NotFoundView instead of do nothing while clicking the deeplink., so I updated the proposal to cover 2 cases.

  1. The console error (which is also this issue)
  2. The NotFoundView when user clicked the link.

So the issue (https://github.com/Expensify/App/issues/28318) can cover this one. Anyway I think let hear other thoughts from @iwiznia and @fedirjh

trjExpensify commented 11 months ago

πŸ‘‹ @iwiznia & @fedirjh we haven't really got time to dally on this issue if it's not the same root cause. It's a crash in the middle of the request money flow, and it's going live to TU on Tuesday. Can you check the above, please? In the meantime, @AndrewGable can you put your thoughts on this so we're ready to move forward if we need to.

fedirjh commented 11 months ago

I faced this many times on the pages where options list is used. We should fix that bug

@aimane-chnaif It's the same bug initially reported in https://github.com/Expensify/App/issues/28318


@trjExpensify I agree with @hungvu193 that this has the same root cause as #28318 , Also this solution is the same as what @hungvu193 has suggested in https://github.com/Expensify/App/issues/28318#issuecomment-1737597028

aimane-chnaif commented 11 months ago

This is what I suggest as this seems like urgent, https://github.com/Expensify/App/issues/28318 is non-urgent. No need to waste time arguing because of issue conflict.

If https://github.com/Expensify/App/issues/28318 will be fixed quickly (in a day or so), go ahead and close this one. If not, we can do quick fix here for the crash. And implement not found logic separately on https://github.com/Expensify/App/issues/28318.

I just found another crash case on split bill.

trjExpensify commented 11 months ago

Yeah, I think we need to get a PR up to fix this crash in the request money flow today, especially if it's also in the split bill case.

I like the idea of using this issue to fix the crash with the above solution, and #28318 to introduce this "no page found" blocking form in the scenario being discussed there.

@mountiny do you agree? We need to resolve this pretty urgently.

mountiny commented 11 months ago

Coming from Slack thread here, going to assing @hungvu193 as their solution was proposed earlier albeit on different issue. it was related.

melvin-bot[bot] commented 11 months ago

πŸ“£ @aimane-chnaif πŸŽ‰ An offer has been automatically sent to your Upwork account for the Reviewer role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job

melvin-bot[bot] commented 11 months ago

πŸ“£ @hungvu193 πŸŽ‰ An offer has been automatically sent to your Upwork account for the Contributor role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review πŸ§‘β€πŸ’» Keep in mind: Code of Conduct | Contributing πŸ“–

melvin-bot[bot] commented 11 months ago

🎯 ⚑️ Woah @aimane-chnaif / @hungvu193, great job pushing this forwards! ⚑️

The pull request got merged within 3 working days of assignment, so this job is eligible for a 50% #urgency bonus πŸŽ‰

On to the next one πŸš€

melvin-bot[bot] commented 11 months ago

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

melvin-bot[bot] commented 11 months ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 1.3.83-11 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-20. :confetti_ball:

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.

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:

melvin-bot[bot] commented 11 months ago

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:

melvin-bot[bot] commented 11 months ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 1.3.83-11 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-20. :confetti_ball:

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.

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:

melvin-bot[bot] commented 11 months ago

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:

melvin-bot[bot] commented 11 months ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 1.3.84-10 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-23. :confetti_ball:

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.

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:

melvin-bot[bot] commented 11 months ago

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:

melvin-bot[bot] commented 11 months ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 1.3.84-10 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-23. :confetti_ball:

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.

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:

melvin-bot[bot] commented 11 months ago

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:

melvin-bot[bot] commented 11 months ago

@AndrewGable, @trjExpensify, @hungvu193, @aimane-chnaif Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

trjExpensify commented 11 months ago

Can we get the checklist filled out please, @aimane-chnaif? Also, not sure why 4 checklists got triggered. πŸ˜…

aimane-chnaif commented 11 months ago

This is already added in guideline - https://github.com/Expensify/App/blob/main/contributingGuides/STYLE.md#how-do-i-auto-focus-a-textinput-using-usefocuseffect If everyone follows this pattern correctly, this bug won't happen.

aimane-chnaif commented 11 months ago

Also, not sure why 4 checklists got triggered. πŸ˜…

https://expensify.slack.com/archives/C01GTK53T8Q/p1698059102119519 πŸ˜„

trjExpensify commented 11 months ago

Okay, so confirming payments as follows:

urgency bonus applied as per here.

trjExpensify commented 11 months ago

Settled up!