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

[$250] Copilot - App crashes after switching account #49939

Closed
6 tasks done
lanitochka17 opened this issue Sep 30, 2024 · 11 comments
Closed
6 tasks done

[$250] Copilot - App crashes after switching account #49939

lanitochka17 opened this issue Sep 30, 2024 · 11 comments
Assignees
Labels
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

@lanitochka17
Copy link

lanitochka17 commented Sep 30, 2024

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


Version Number: 9.0.41-2
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

    • Log in as a copilot
  1. Go to staging.new.expensify.com
  2. Go to Inbox (important)
  3. Go to Account settings
  4. Click on the account switcher
  5. Select another account

Expected Result:

App will not crash

Actual Result:

App crashes after switching account

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

Bug6618752_1727547900276.20240929_022127.mp4

logs (2).txt

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021840797218276068437
  • Upwork Job ID: 1840797218276068437
  • Last Price Increase: 2024-09-30
  • Automatic offers:
    • rojiphil | Reviewer | 104271871
Issue OwnerCurrent Issue Owner: @rojiphil
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 30, 2024
Copy link

melvin-bot bot commented Sep 30, 2024

Triggered auto assignment to @twisterdotcom (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@bernhardoj
Copy link
Contributor

Proposal

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

App crashes when switching account.

What is the root cause of that problem?

As shown by the error on the console, the error caused by the useOnyx keys changes from a member collection key to the whole collection key (in this case, reportNameValuePairs_xx to reportNameValuePairs_).

The error is thrown specifically from

const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`);
.

When switching accounts, the report becomes undefined and we default the reportID attribute to an empty string.

const report = useMemo(
(): OnyxEntry<OnyxTypes.Report> =>
reportOnyx && {
lastReadTime: reportOnyx.lastReadTime,
reportID: reportOnyx.reportID ?? '',

Because empty string is not undefined/null, report?.reportID ?? -1 will still be an empty string.

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

We need to use || instead of ??

const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || '-1'}`);

I see that we use ?? for REPORT_NAME_VALUE_PAIRS in several places too, we can replace them all with || too.

@abzokhattab
Copy link
Contributor

Proposal

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

App crashes when switching account.

What is the root cause of that problem?

when switiching the accounts, the following oynx key is resolved as reportNameValuePairs_

const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`);

This occurs because when switching, the report becomes empty. Since we are constructing the report object in this context, the report ID fallback value is set to an empty string instead of -1:

reportID: reportOnyx.reportID ?? '',

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

we should change the fallback value here to -1 instead of the empty string:

                reportID: reportOnyx.reportID ?? -1,

What alternative solutions did you explore? (Optional)

@twisterdotcom twisterdotcom added the External Added to denote the issue can be worked on by a contributor label Sep 30, 2024
@melvin-bot melvin-bot bot changed the title Copilot - App crashes after switching account [$250] Copilot - App crashes after switching account Sep 30, 2024
Copy link

melvin-bot bot commented Sep 30, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 30, 2024
Copy link

melvin-bot bot commented Sep 30, 2024

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

@rojiphil
Copy link
Contributor

Thanks for the proposals.
The root cause is that the report id becomes an empty string. Falling back to -1 will solve this issue.
@bernhardoj proposal LGTM
🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Sep 30, 2024

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

Copy link

melvin-bot bot commented Oct 4, 2024

@rojiphil, @twisterdotcom, @jasperhuangg Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Oct 4, 2024
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 4, 2024
Copy link

melvin-bot bot commented Oct 4, 2024

📣 @rojiphil 🎉 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 melvin-bot bot removed the Overdue label Oct 4, 2024
@bernhardoj
Copy link
Contributor

This is fixed in #49255.

@rojiphil
Copy link
Contributor

rojiphil commented Oct 5, 2024

This is fixed in #49255.

Ok. Let's close this then and move on cc @twisterdotcom @jasperhuangg

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

No branches or pull requests

6 participants