Skip to content

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

Closed

Description

@lanitochka17

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: 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): applausetester+kaaaa@applause.expensifail.com
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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 30, 2024
  2. melvin-bot commented on Sep 30, 2024

    @melvin-bot

    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.

  3. bernhardoj commented on Sep 30, 2024

    @bernhardoj
    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.

  4. abzokhattab commented on Sep 30, 2024

    @abzokhattab
    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)

  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 30, 2024
  6. changed the title [-]Copilot - App crashes after switching account[/-] [+][$250] Copilot - App crashes after switching account[/+] on Sep 30, 2024
  7. melvin-bot commented on Sep 30, 2024

    @melvin-bot
  8. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 30, 2024
  9. melvin-bot commented on Sep 30, 2024

    @melvin-bot

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

  10. rojiphil commented on Sep 30, 2024

    @rojiphil
    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

  11. melvin-bot commented on Sep 30, 2024

    @melvin-bot

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

  12. melvin-bot commented on Oct 4, 2024

    @melvin-bot

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

  13. removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 4, 2024
  14. melvin-bot commented on Oct 4, 2024

    @melvin-bot

    📣 @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

  15. bernhardoj commented on Oct 5, 2024

    @bernhardoj
    Contributor

    This is fixed in #49255.

  16. rojiphil commented on Oct 5, 2024

    @rojiphil
    Contributor

    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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions