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 2024-05-22] [$250] Categories - Unable to go to other tabs after enabling " must categorize all spend" offline #41325

Closed
6 tasks done
kbecciv opened this issue Apr 30, 2024 · 31 comments
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

@kbecciv
Copy link

kbecciv commented Apr 30, 2024

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.68-0
Reproducible in staging?: y
Reproducible in production?: y
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go offline.
  3. Go to Account settings > Workspaces.
  4. Create a new workspace.
  5. Go to Categories.
  6. Click Settings.
  7. Toggle on "Members must categorize all spend".
  8. Close the RHP.
  9. Navigate to other tabs.

Expected Result:

User should be able to navigate to other tabs after toggling on "Members must categorize all spend" offline.

Actual Result:

User is blocked from clicking on other tabs after toggling on "Members must categorize all spend" offline.

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

Bug6466535_1714480419141.20240430_202756.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~014991e62b8f3dcfbf
  • Upwork Job ID: 1785348526516846592
  • Last Price Increase: 2024-04-30
  • Automatic offers:
    • ikevin127 | Reviewer | 0
    • Nodebrute | Contributor | 0
Issue OwnerCurrent Issue Owner: @joekaufmanexpensify
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Apr 30, 2024
Copy link

melvin-bot bot commented Apr 30, 2024

Triggered auto assignment to @joekaufmanexpensify (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.

@kbecciv
Copy link
Author

kbecciv commented Apr 30, 2024

We think that this bug might be related to #wave-collect - Release 1

@kbecciv
Copy link
Author

kbecciv commented Apr 30, 2024

@joekaufmanexpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors.

@joekaufmanexpensify
Copy link
Contributor

It doesn't only happen when you're offline. If you create a new workspace while online and enable this feature, it precludes accessing tabs in the workspace editor. Definitely a bug.

2024-04-30_12-39-00.mp4

@joekaufmanexpensify joekaufmanexpensify added the External Added to denote the issue can be worked on by a contributor label Apr 30, 2024
@melvin-bot melvin-bot bot changed the title Categories - Unable to go to other tabs after enabling " must categorize all spend" offline [$250] Categories - Unable to go to other tabs after enabling " must categorize all spend" offline Apr 30, 2024
Copy link

melvin-bot bot commented Apr 30, 2024

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

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

melvin-bot bot commented Apr 30, 2024

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

@Nodebrute
Copy link
Contributor

Nodebrute commented Apr 30, 2024

Proposal

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

Categories - Unable to go to other tabs after enabling " must categorize all spend" offline

What is the root cause of that problem?

Policy.errors will always be true instead we should check if it's an empty object

const hasPolicyCreationError = !!(policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && policy.errors);

Enabling categories will make both of the above conditions true, which will result in all options being disabled.
disabled={hasPolicyCreationError || isExecuting}

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

Instead of policy.error we should check for !isEmptyObject(policy.errors)
const hasPolicyCreationError = !!(policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && !isEmptyObject(policy.errors));

const hasPolicyCreationError = !!(policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && policy.errors);

Warning

I don't think we should use errors: null. If the policy had previous errors, enabling categories will reset all errors to null.

What alternative solutions did you explore? (Optional)

@ShridharGoel
Copy link
Contributor

ShridharGoel commented Apr 30, 2024

Proposal

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

What is the root cause of that problem?

Optimistic data and success data is setting errors to an object with requiresCategory.

App/src/libs/actions/Policy.ts

Lines 3571 to 3599 in 942c851

optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
requiresCategory,
errors: {
requiresCategory: null,
},
pendingFields: {
requiresCategory: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
},
},
],
successData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
errors: {
requiresCategory: null,
},
pendingFields: {
requiresCategory: null,
},
},
},
],

For tags, same issue is there using requiresTag.

App/src/libs/actions/Policy.ts

Lines 4355 to 4381 in 942c851

optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
requiresTag,
errors: {requiresTag: null},
pendingFields: {
requiresTag: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
},
},
],
successData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
errors: {
requiresTag: null,
},
pendingFields: {
requiresTag: null,
},
},
},
],

This leads to hasPolicyCreationError becoming true in WorkspaceInitialPage.

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

In the optimistic data, errors should be set to null for categories and tags.

function setWorkspaceRequiresCategory(policyID: string, requiresCategory: boolean) {
    const onyxData: OnyxData = {
        optimisticData: [
            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
                value: {
                    requiresCategory,
-                  errors: {
-                      requiresCategory: null,
-                  },
+                  errors: null,
                    pendingFields: {
                        requiresCategory: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
                    },
                },
            },
        ],
        successData: [
            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
                value: {
-                  errors: {
-                      requiresCategory: null,
-                  },
+                  errors: null,
                    pendingFields: {
                        requiresCategory: null,
                    },
                },
            },
        ],
        failureData: [
            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
                value: {
                    requiresCategory: !requiresCategory,
                    errors: ErrorUtils.getMicroSecondOnyxError('workspace.categories.updateFailureMessage'),
                    pendingFields: {
                        requiresCategory: null,
                    },
                },
            },
        ],
    };

    const parameters = {
        policyID,
        requiresCategory,
    };

    API.write(WRITE_COMMANDS.SET_WORKSPACE_REQUIRES_CATEGORY, parameters, onyxData);
}

The method for tags setPolicyRequiresTag also needs to be updated.

Same change is needed for tags.

We should also update the check in hasPolicyCreationError to !isEmptyObject(policy.errors) instead of policy.errors.

@ntdiary
Copy link
Contributor

ntdiary commented May 1, 2024

Hi, @joekaufmanexpensify, I'll be OOO for the next two weeks. Could you please reassign another c+? :)

@joekaufmanexpensify
Copy link
Contributor

Will do!

@joekaufmanexpensify joekaufmanexpensify added External Added to denote the issue can be worked on by a contributor and removed External Added to denote the issue can be worked on by a contributor labels May 1, 2024
Copy link

melvin-bot bot commented May 1, 2024

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

@ikevin127
Copy link
Contributor

♻️ Reviewing proposals.

@ikevin127
Copy link
Contributor

@Nodebrute's proposal looks good to me! They were first to identify the root cause and propose the isEmptyObject solution which fixes the issue accordingly.

I agree with the note that we shouldn't set errors: null because if the policy previously had errors, these will be cleared when toggling Categories > "Members must categorize all spend" or Tags > "Members must tag all spend", which would create a regression.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented May 1, 2024

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

@ikevin127
Copy link
Contributor

@ShridharGoel Given that the first proposal identified the RCA and proposed the isEmptyObject solution first, please let me know if you think there's something I'm missing from your solution which would require the errors: null part your solution suggests.

If I'm missing anything please let me know and if the argument for your version of the solution is solid then I'll reconsider assignment.

@Nodebrute
Copy link
Contributor

@chiragsalian Waiting to be assigned.

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

melvin-bot bot commented May 2, 2024

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

Copy link

melvin-bot bot commented May 2, 2024

📣 @Nodebrute 🎉 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 📖

@Nodebrute Nodebrute mentioned this issue May 4, 2024
50 tasks
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels May 4, 2024
@joekaufmanexpensify
Copy link
Contributor

PR on staging

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels May 15, 2024
@melvin-bot melvin-bot bot changed the title [$250] Categories - Unable to go to other tabs after enabling " must categorize all spend" offline [HOLD for payment 2024-05-22] [$250] Categories - Unable to go to other tabs after enabling " must categorize all spend" offline May 15, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 15, 2024
Copy link

melvin-bot bot commented May 15, 2024

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

Copy link

melvin-bot bot commented May 15, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.73-7 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 2024-05-22. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented May 15, 2024

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:

@joekaufmanexpensify
Copy link
Contributor

@ikevin127 please handle BZ checklist so we can issue payment this week

@ikevin127
Copy link
Contributor

ikevin127 commented May 20, 2024

  • [@ikevin127] The PR that introduced the bug has been identified. Link to the PR: Show errors after workspace creation failure #12117
  • [@ikevin127] 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: #12117 (comment).
  • [@ikevin127] 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:

No need to start a discussion as the logic that introduced this issue was written in 2022 back when we were using React class components and plain javascript. Since then we migrated to React functional components and typescript which means that this kind of faulty logic is less likely to be written.

  • [@ikevin127] Determine if we should create a regression test for this bug.
  • [@ikevin127] 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.

Regression Test Proposal

  1. Go offline.
  2. Go to Account settings > Workspaces.
  3. Create a new workspace.
  4. Go to Categories.
  5. Click Settings.
  6. Toggle on "Members must categorize all spend".
  7. Close the RHP.
  8. Verify that you can navigate to other tabs of the workspace settings (left sidebar).

Do we agree 👍 or 👎.

cc @joekaufmanexpensify

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels May 21, 2024
@joekaufmanexpensify
Copy link
Contributor

Checklist all set.

@joekaufmanexpensify
Copy link
Contributor

All set to issue payment! We need to pay:

@joekaufmanexpensify
Copy link
Contributor

@Nodebrute $250 sent and contract ended!

@joekaufmanexpensify
Copy link
Contributor

@ikevin127 $250 sent and contract ended!

@joekaufmanexpensify
Copy link
Contributor

Upwork job closed.

@joekaufmanexpensify
Copy link
Contributor

All set, thanks everyone!

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
No open projects
Archived in project
Development

No branches or pull requests

7 participants