Skip to content

[HOLD for payment 2023-12-06] [$500] Assign Task - The app crashes when canceling a task in offline mode #31587

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: 1.4.1-4
Reproducible in staging?: Y
Reproducible in production?: Y
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: Applause - Internal Team
Slack conversation:

Action Performed:

Pre-condition: In LHN task received on previous date with green dot is required

  1. Launch app
  2. Tap on profile---Preferences
  3. Toggle on forced offline
  4. Navigaye to LHN
  5. Tap on task received on previous dates with greet dot
  6. Tap on 3 dots on top right
  7. Tap cancel

Expected Result:

PAs receiver of task login and cancel task in offline, app must not crash

Actual Result:

The app crashes when canceling a task in offline mode

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

Bug6284569_1700516313998.task.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a371f1783ea64c60
  • Upwork Job ID: 1726719421226061824
  • Last Price Increase: 2023-11-20
  • Automatic offers:
    • abzokhattab | Contributor | 27770841

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Nov 20, 2023
  2. changed the title [-]Assign Task - The app crashes when canceling a task in offline mode[/-] [+][$500] Assign Task - The app crashes when canceling a task in offline mode[/+] on Nov 20, 2023
  3. melvin-bot commented on Nov 20, 2023

    @melvin-bot

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

  4. melvin-bot commented on Nov 20, 2023

    @melvin-bot
  5. melvin-bot commented on Nov 20, 2023

    @melvin-bot

    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
  6. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Nov 20, 2023
  7. melvin-bot commented on Nov 20, 2023

    @melvin-bot

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

  8. abzokhattab commented on Nov 20, 2023

    @abzokhattab
    Contributor

    Proposal

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

    App crashes on canceling a task in offline mode

    What is the root cause of that problem?

    The app throws the following err in this line:

    lastVisibleActionCreated: ReportActionsUtils.getLastVisibleAction(parentReport.reportID, optimisticReportActions).created,

    image

    this happens because the getLastVisibleAction function returns null in this line with resulting in the prev err:

    if (sortedReportActions.length === 0) {
    return null;
    }

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

    use lodash to access the .created prop as we are doing here

                    lastVisibleActionCreated: lodashGet(ReportActionsUtils.getLastVisibleAction(parentReport.reportID, optimisticReportActions),'created'),
    
    
  9. dukenv0307 commented on Nov 21, 2023

    @dukenv0307
    Contributor

    Proposal

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

    App crashes when canceling a task in offline mode

    What is the root cause of that problem?

    When we receive a task and go offline before visiting the task report, this report will have no report action.

    So getLastVisibleAction return null

    if (sortedReportActions.length === 0) {
    return null;
    }

    and then the app crashes here
    lastVisibleActionCreated: ReportActionsUtils.getLastVisibleAction(parentReport.reportID, optimisticReportActions).created,

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

    If sortedReportActions is an empty array we should return an empty object instead of returning null. That can make sure that all places that use getLastVisibleAction will not make the app crash

    if (sortedReportActions.length === 0) {
    return null;
    }

    We also need to check all places are calling this function to see if it is used like action.key1.key2 we should use lodashGet for this.

    What alternative solutions did you explore? (Optional)

  10. narefyev91 commented on Nov 21, 2023

    @narefyev91
    Contributor

    Proposal from @abzokhattab looks good to me #31587 (comment)
    We should just fix correct usage for lastVisibleActionCreated
    Based on this PR https://github.com/Expensify/App/pull/28570/files - we already moved away from returning {} (which will break TS paradigm for that function and may lead to more regressions @dukenv0307 based on your suggestion)
    Problem also was not discovered before because not everything are in TS. That's why error was not caught.
    Also my suggestion will be to add more unit test here tests/unit/ReportActionsUtilsTest.js for getLastVisibleAction function
    🎀 👀 🎀 C+ reviewed

  11. 12 remaining items

  12. changed the title [-][$500] Assign Task - The app crashes when canceling a task in offline mode[/-] [+][HOLD for payment 2023-12-06] [$500] Assign Task - The app crashes when canceling a task in offline mode[/+] on Nov 29, 2023
  13. melvin-bot commented on Nov 29, 2023

    @melvin-bot

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

  14. melvin-bot commented on Nov 29, 2023

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.4-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-12-06. 🎊

    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:

  15. melvin-bot commented on Nov 29, 2023

    @melvin-bot

    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:

    • [@narefyev91] The PR that introduced the bug has been identified. Link to the PR:
    • [@narefyev91] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
    • [@narefyev91] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
    • [@narefyev91] Determine if we should create a regression test for this bug.
    • [@narefyev91] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
    • [@sonialiap] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  16. sonialiap commented on Dec 7, 2023

    @sonialiap
    Contributor

    @abzokhattab contributor $500 - paid ✔️

  17. sonialiap commented on Dec 7, 2023

    @sonialiap
    Contributor

    @narefyev91 please complete the checklist :)

  18. narefyev91 commented on Dec 7, 2023

    @narefyev91
    Contributor
    • The PR that introduced the bug has been identified. Link to the PR - was not coming from regression - just missing additional check to prevent crash
    • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment - N/A
    • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion - N/A
    • Determine if we should create a regression test for this bug - N/A
  19. sonialiap commented on Dec 8, 2023

    @sonialiap
    Contributor

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething 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