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 payment 2023-08-21] [$1000] App crashes when deleting workspace while in offline mode #24062

Closed
1 of 6 tasks
kavimuru opened this issue Aug 2, 2023 · 26 comments
Closed
1 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production 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

@kavimuru
Copy link

kavimuru commented Aug 2, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Open ND
  2. Create 5 workspaces & make sure you have 5 active workspaces
  3. Apply offline network mode in dev tools
  4. Delete 2 workspaces in offline mode
  5. Close RHN > click on 'Profile' avatar & navigate to Settings page
  6. Apply 'No throttling' in dev tools while 'Settings' page is opened

Expected Result:

App shouldn'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?

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

Version Number: 1.3.49-0
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
Notes/Photos/Videos: Any additional supporting documentation

Recording.1435.mp4

Expensify/Expensify Issue URL:
Issue reported by: @Natnael-Guchima
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1690459285350399

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01ab283e641a86aa39
  • Upwork Job ID: 1688971711391633408
  • Last Price Increase: 2023-08-08
  • Automatic offers:
    • fedirjh | Reviewer | 26028363
    • s-alves10 | Contributor | 26028364
    • natnael-guchima | Reporter | 26028365
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 2, 2023

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

@melvin-bot
Copy link

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

@Natnael-Guchima
Copy link

Video to reproduce the issue.

Screencast.from.2023-08-02.19-13-38.mp4

@Pujan92
Copy link
Contributor

Pujan92 commented Aug 2, 2023

Proposal

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

App crashes when deleting the workspaces(from more than 4 to 4 or less) offline and turns to online

What is the root cause of that problem?

For showing the extra number of items overlay in MultipleAvatars we are using a condition here with the avatars.length and inside that block for one of the styles we used props.icons[3] here.

{avatars.length > props.maxAvatarsInRow && (

The issue is props.icons we received from the parent and on the deletion of the workspace items props.icons will be reduced/updated. But on the other side avatarRows won't be updated immediately as it needs to be calculated from the useEffect block here and that leads to the error of accessing field type of undefined.

Screenshot 2023-08-03 at 1 24 15 AM

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

We need to use avatars[3].type instead of props.icons[3].type as that we used for the rendering of the extra number of items overlay.

props.icons[3].type === CONST.ICON_TYPE_WORKSPACE ? StyleUtils.getAvatarBorderRadius(props.size, props.icons[3].type) : {},

@namhihi237
Copy link
Contributor

namhihi237 commented Aug 2, 2023

Proposal

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

The app shouldn't crash

What is the root cause of that problem?

When online we have 5 icons then this code is correct.

props.icons[3].type === CONST.ICON_TYPE_WORKSPACE ? StyleUtils.getAvatarBorderRadius(props.size, props.icons[3].type) : {},

But after deleting 2 items, on the setting side, we still show 5 workspaces here. When back online, the new workspace is deleted resulting in props.icons with only 3 items but the change here useEffect will update avatarRows again later resulting in props.icons[3] undefined causing the crash.

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

We can use avatars.
Also we should use props.maxAvatarsInRow - 1 instead of hard 3.

avatars[props.maxAvatarsInRow -1].type === CONST.ICON_TYPE_WORKSPACE ? StyleUtils.getAvatarBorderRadius(props.size, avatars[props.maxAvatarsInRow - 1].type) : {},

What alternative solutions did you explore? (Optional)

props.icons.length > props.maxAvatarsInRow -1 && props.icons[props.maxAvatarsInRow -1].type === CONST.ICON_TYPE_WORKSPACE ? StyleUtils.getAvatarBorderRadius(props.size, props.icons[props.maxAvatarsInRow -1].type) : {},

@s-alves10
Copy link
Contributor

s-alves10 commented Aug 3, 2023

Proposal

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

App crashes when deleting workspaces in offline mode and back to online

What is the root cause of that problem?

After deleting 2 workspaces and go to settings page, we have 5 workspaces including pending deletion. So MultipleAvatar component shows 5 icons.
When switching to online mode, 2 workspaces are deleted and props.icons would have length 3. As you know, useEffect is called after rendering if at least one of its dependencies changes. So at the first rendering after props.icons is changed, props.icons.length = 3, and avatars.length = 5. This causes the app crash

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

We have to synchronize the avatarRows data and props.icons. This is impossible using useEffect due to its nature.
This is the perfect use case of useMemo.

Remove the useState and useEffect and combine them into one useMemo

    const avatarRows = useMemo(() => {
        if (!props.shouldDisplayAvatarsInRows || props.icons.length <= props.maxAvatarsInRow) {
            return [props.icons];
        }

        // Calculate the size of each row
        const rowSize = Math.min(Math.ceil(props.icons.length / 2), props.maxAvatarsInRow);

        // Slice the icons array into two rows
        const firstRow = props.icons.slice(rowSize);
        const secondRow = props.icons.slice(0, rowSize);

        // Update the state with the two rows as an array
        return [firstRow, secondRow];
    }, [props.icons, props.maxAvatarsInRow, props.shouldDisplayAvatarsInRows]);

This way, we can sync the avatarRows and props.icons

Result
24062.mp4

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Aug 4, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 7, 2023

@sonialiap Eep! 4 days overdue now. Issues have feelings too...

@sonialiap
Copy link
Contributor

Triaging to external

@melvin-bot melvin-bot bot removed the Overdue label Aug 8, 2023
@sonialiap sonialiap added the External Added to denote the issue can be worked on by a contributor label Aug 8, 2023
@melvin-bot melvin-bot bot changed the title App crashes when deleting workspace while in offline mode [$1000] App crashes when deleting workspace while in offline mode Aug 8, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 8, 2023

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

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

melvin-bot bot commented Aug 8, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 8, 2023

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

@fedirjh
Copy link
Contributor

fedirjh commented Aug 8, 2023

I think @s-alves10's proposal makes sense to me, it appears to fix the root cause. This bug seems to arise from recent functional refactor.

🎀 👀 🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Aug 8, 2023

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

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

melvin-bot bot commented Aug 9, 2023

📣 @fedirjh 🎉 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
Copy link

melvin-bot bot commented Aug 9, 2023

📣 @s-alves10 🎉 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
Copy link

melvin-bot bot commented Aug 9, 2023

📣 @Natnael-Guchima 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@s-alves10
Copy link
Contributor

Thank you
I'll create a PR in a few hours

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Aug 9, 2023
@s-alves10
Copy link
Contributor

@fedirjh

PR is ready for review

@melvin-bot
Copy link

melvin-bot bot commented Aug 10, 2023

🎯 ⚡️ Woah @fedirjh / @s-alves10, 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 🎉

  • when @s-alves10 got assigned: 2023-08-09 12:46:07 Z
  • when the PR got merged: 2023-08-10 08:52:30 UTC

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Aug 14, 2023
@melvin-bot melvin-bot bot changed the title [$1000] App crashes when deleting workspace while in offline mode [HOLD for payment 2023-08-21] [$1000] App crashes when deleting workspace while in offline mode Aug 14, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Aug 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 14, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 14, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.53-2 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-08-21. 🎊

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:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Aug 14, 2023

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:

  • [@fedirjh] The PR that introduced the bug has been identified. Link to the PR:
  • [@fedirjh] 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:
  • [@fedirjh] 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:
  • [@fedirjh] Determine if we should create a regression test for this bug.
  • [@fedirjh] 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:

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 Daily KSv2 labels Aug 21, 2023
@techievivek
Copy link
Contributor

Not overdue, waiting for payment to be done.

@melvin-bot melvin-bot bot removed the Overdue label Aug 23, 2023
@fedirjh fedirjh mentioned this issue Aug 23, 2023
56 tasks
@fedirjh
Copy link
Contributor

fedirjh commented Aug 23, 2023

BugZero Checklist:


Regression Test Proposal

  1. Open App
  2. Create 5 workspaces or make sure you have 5 active workspaces
  3. Go offline
  4. Delete 2 workspaces
  5. Close RHN and click Profile avatar to go to the settings page
  6. Go online
  7. Verify that the app doesn't crash and 3 workspaces are left
  • Do we agree 👍 or 👎

@melvin-bot melvin-bot bot added the Overdue label Aug 28, 2023
@techievivek
Copy link
Contributor

Regression test proposal looks good to me, let's wait for @sonialiap to get this added to the testRail.

@melvin-bot melvin-bot bot removed the Overdue label Aug 28, 2023
@sonialiap
Copy link
Contributor

Sorry for the delay, back from OOO and sending payments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production 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

8 participants