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] Categories - Employee has the option to edit categories when all the categories are disabled #48097

Closed
1 of 6 tasks
lanitochka17 opened this issue Aug 27, 2024 · 23 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Aug 27, 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.25-1
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4895538
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

  • Admin and employee are in the same workspace
  1. Go to staging.new.expensify.com
  2. [Employee] Go to workspace chat
  3. [Employee] Click + > Submit expense > Manual
  4. {Employee] Enter amount > Next
  5. [Employee] Click Category on the confirmation page
  6. [Admin] Disable all the categories

Expected Result:

Category page will turn to not here page for employee after admin disables all the categories

Actual Result:

Category page turns to empty state page with Edit categories button for employee which leads to not here page

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

Bug6584008_1724750744231.20240827_172136.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01775966fb678bc1d8
  • Upwork Job ID: 1828566383512584614
  • Last Price Increase: 2024-08-27
  • Automatic offers:
    • DylanDylann | Reviewer | 103734142
    • nkdengineer | Contributor | 103734143
Issue OwnerCurrent Issue Owner: @DylanDylann
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 27, 2024
Copy link

melvin-bot bot commented Aug 27, 2024

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

@lanitochka17
Copy link
Author

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

@lanitochka17
Copy link
Author

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

Copy link

melvin-bot bot commented Aug 27, 2024

📣 @akshsekhr2702! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@FitseTLT
Copy link
Contributor

FitseTLT commented Aug 27, 2024

Edited by proposal-police: This proposal was edited at 2024-08-27 14:56:45 UTC.

Proposal

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

Categories - Employee has the option to edit categories when all the categories are disabled

What is the root cause of that problem?

We are not checking if the user can update category when we display empty state section here

{shouldShowEmptyState && (
<View style={[styles.flex1]}>
<WorkspaceEmptyStateSection
shouldStyleAsCard={false}

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

We can check if the user is admin before displaying the empty section

const shouldShowEmptyState = !isLoading && !shouldShowCategory;

    const shouldShowEmptyState = !isLoading && !shouldShowCategory && isPolicyAdmin(policy);

and display not found page when it is not policy admin and no categories in the list

const shouldShowNotFoundPage = isEditing && (isSplitBill ? !canEditSplitBill : !ReportActionsUtils.isMoneyRequestAction(reportAction) || !ReportUtils.canEditMoneyRequest(reportAction));

const shouldShowNotFoundPage =
        (isEditing && (isSplitBill ? !canEditSplitBill : !ReportActionsUtils.isMoneyRequestAction(reportAction) || !ReportUtils.canEditMoneyRequest(reportAction))) ||
        (!isLoading && !shouldShowCategory && !isPolicyAdmin(policy));

What alternative solutions did you explore? (Optional)

@nkdengineer
Copy link
Contributor

nkdengineer commented Aug 27, 2024

Edited by proposal-police: This proposal was edited at 2024-08-27 15:01:22 UTC.

Proposal

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

Category page turns to empty state page with Edit categories button for employee which leads to not here page

What is the root cause of that problem?

We always show the edit category button even the user is not an admin of the workspace

<FixedFooter style={[styles.mtAuto, styles.pt5]}>

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

We can use isPolicyAdmin function to check whether the user is an admin or not then use it to show the edit category button or we can add disabled prop for this button with isPolicyAdmin check.

PolicyUtils.isPolicyAdmin(policy) && (
    // Edit category button
)

OPTIONAL: We can display another message like Ask the admin to edit the category
We should still show the empty state component

What alternative solutions did you explore? (Optional)

If we want to display not found page in this case, we can add the condition to show not found page if shouldShowEmptyState is true and the user isn't the admin of the WS

const shouldShowNotFoundPage = (isEditing && (isSplitBill ? !canEditSplitBill : !ReportActionsUtils.isMoneyRequestAction(reportAction) || !ReportUtils.canEditMoneyRequest(reportAction))) || (shouldShowEmptyState && !PolicyUtils.isPolicyAdmin(policy));

const shouldShowNotFoundPage = isEditing && (isSplitBill ? !canEditSplitBill : !ReportActionsUtils.isMoneyRequestAction(reportAction) || !ReportUtils.canEditMoneyRequest(reportAction));

@Krishna2323
Copy link
Contributor

Krishna2323 commented Aug 27, 2024

Proposal

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

Categories - Employee has the option to edit categories when all the categories are disabled

What is the root cause of that problem?

The shouldShowNotFoundPage variable isn't checking if the user is a admin or not.

const shouldShowNotFoundPage = isEditing && (isSplitBill ? !canEditSplitBill : !ReportActionsUtils.isMoneyRequestAction(reportAction) || !ReportUtils.canEditMoneyRequest(reportAction));

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

We can update the condition:

const shouldShowNotFoundPage = isEditing && (isSplitBill ? !canEditSplitBill : !ReportActionsUtils.isMoneyRequestAction(reportAction) || !ReportUtils.canEditMoneyRequest(reportAction));

TO:

    const shouldShowNotFoundPage =
        (isEditing && (isSplitBill ? !canEditSplitBill : !ReportActionsUtils.isMoneyRequestAction(reportAction) || !ReportUtils.canEditMoneyRequest(reportAction))) ||
        (PolicyUtils.isPolicyAdmin(policy) && !OptionsListUtils.hasEnabledOptions(Object.values(policyCategories ?? {})));

What alternative solutions did you explore? (Optional)



Result

@nkdengineer
Copy link
Contributor

Updated proposal

  • Add alternative solution

@stephanieelliott stephanieelliott added the External Added to denote the issue can be worked on by a contributor label Aug 27, 2024
@melvin-bot melvin-bot bot changed the title Categories - Employee has the option to edit categories when all the categories are disabled [$250] Categories - Employee has the option to edit categories when all the categories are disabled Aug 27, 2024
Copy link

melvin-bot bot commented Aug 27, 2024

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

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

melvin-bot bot commented Aug 27, 2024

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

@stephanieelliott
Copy link
Contributor

Yea I agree this is not working as expected, there is a delay in hiding the categories once they are disabled.

@DylanDylann
Copy link
Contributor

Thanks everyone, @FitseTLT and @Krishna2323 have the same idea of displaying the not found page. But I prefer to display an empty view as suggested by @nkdengineer. I think we can hide the "Edit category" or update the button text to something like "Got it",... (maybe this will need to be confirmed in the PR phase)

Let's go with @nkdengineer's proposal

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Aug 29, 2024

Triggered auto assignment to @carlosmiceli, 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 29, 2024
Copy link

melvin-bot bot commented Aug 29, 2024

📣 @DylanDylann 🎉 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 Aug 29, 2024

📣 @nkdengineer 🎉 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 melvin-bot bot added Reviewing Has a PR in review and removed Daily KSv2 labels Aug 30, 2024
@melvin-bot melvin-bot bot added the Weekly KSv2 label Aug 30, 2024
@DylanDylann
Copy link
Contributor

@carlosmiceli I see the behavior on other pages is different. With the same step

  • On Tag page: we display not found page
  • On Report field page: we display nothing
  • On Category page (this issue): We are going to display empty view

Should we adjust all these pages to make it consistent

@carlosmiceli
Copy link
Contributor

@DylanDylann that's a good point, we should (I think). Let me get back on this. I think for now we should proceed fixing the issue as originally proposed, and we'll create another issue for standardizing those pages if we want.

@carlosmiceli
Copy link
Contributor

@DylanDylann I'm not being able to reproduce this for Tags for example, it continues to display the Tags until the user reloads the app. Could you show me a video of how you get to each empty screen for Tags and Reports? Thank you!

@DylanDylann
Copy link
Contributor

@carlosmiceli Sorry for my delay. I test in the same admin account and using two chrome tab

Screen.Recording.2024-09-04.at.16.51.44.mov

cc @nkdengineer Could you help to verify the output when login in the 2 account as in the OP with Tag and report field

@stephanieelliott
Copy link
Contributor

This PR should be merged with today's deploy 🎉

@DylanDylann
Copy link
Contributor

DylanDylann commented Sep 24, 2024

@stephanieelliott Please help process payment, thanks

@stephanieelliott
Copy link
Contributor

stephanieelliott commented Sep 24, 2024

Oops, yes looks like the automation didn't work -- PR was deployed to prod with #48791 and should've been paid on 9/19. Setting up for payment now.

@stephanieelliott
Copy link
Contributor

Summarizing payment on this issue:

Upwork job is here: https://www.upwork.com/jobs/~01775966fb678bc1d8

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. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
No open projects
Status: Done
Development

No branches or pull requests

8 participants
@carlosmiceli @stephanieelliott @FitseTLT @lanitochka17 @Krishna2323 @DylanDylann @nkdengineer and others