Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.34k stars 2.77k forks source link

[$250] Categories - Employee has the option to edit categories when all the categories are disabled #48097

Open lanitochka17 opened 3 weeks ago

lanitochka17 commented 3 weeks ago

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.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): applausetester+kh050806@applause.expensifail.com Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

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?

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/user-attachments/assets/80e116b4-6e1a-496c-a5e0-00a326065905

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
melvin-bot[bot] commented 3 weeks ago

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 commented 3 weeks ago

@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 commented 3 weeks ago

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

melvin-bot[bot] commented 3 weeks ago

πŸ“£ @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 commented 3 weeks ago

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 https://github.com/Expensify/App/blob/0fd1de0f279fffba0129484801942c3bddb148da/src/pages/iou/request/step/IOURequestStepCategory.tsx#L170-L173

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 https://github.com/Expensify/App/blob/0fd1de0f279fffba0129484801942c3bddb148da/src/pages/iou/request/step/IOURequestStepCategory.tsx#L114

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

and display not found page when it is not policy admin and no categories in the list https://github.com/Expensify/App/blob/0fd1de0f279fffba0129484801942c3bddb148da/src/pages/iou/request/step/IOURequestStepCategory.tsx#L103

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

What alternative solutions did you explore? (Optional)

nkdengineer commented 3 weeks ago

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

https://github.com/Expensify/App/blob/6ca91cddfbb4bbcd0ca24c9f10549057b6fd7332/src/pages/iou/request/step/IOURequestStepCategory.tsx#L179

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));

https://github.com/Expensify/App/blob/6ca91cddfbb4bbcd0ca24c9f10549057b6fd7332/src/pages/iou/request/step/IOURequestStepCategory.tsx#L103

Krishna2323 commented 3 weeks ago

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. https://github.com/Expensify/App/blob/6ca91cddfbb4bbcd0ca24c9f10549057b6fd7332/src/pages/iou/request/step/IOURequestStepCategory.tsx#L103

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

We can update the condition: https://github.com/Expensify/App/blob/6ca91cddfbb4bbcd0ca24c9f10549057b6fd7332/src/pages/iou/request/step/IOURequestStepCategory.tsx#L103

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 commented 3 weeks ago

Updated proposal

melvin-bot[bot] commented 2 weeks ago

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

melvin-bot[bot] commented 2 weeks ago

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

stephanieelliott commented 2 weeks ago

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

DylanDylann commented 2 weeks ago

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

melvin-bot[bot] commented 2 weeks ago

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

melvin-bot[bot] commented 2 weeks ago

πŸ“£ @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

melvin-bot[bot] commented 2 weeks ago

πŸ“£ @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 πŸ“–

DylanDylann commented 2 weeks ago

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

Should we adjust all these pages to make it consistent

carlosmiceli commented 2 weeks ago

@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 commented 2 weeks ago

@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 commented 1 week ago

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

https://github.com/user-attachments/assets/290af9b7-2e30-42e2-8a15-a13767588a17

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 commented 6 days ago

This PR should be merged with today's deploy πŸŽ‰