Skip to content

[HOLD for payment 2024-10-10] [$250] Category rules - Approver field is blank for a moment after editing category name #49293

Closed

Description

@IuliiaHerets

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.35-0
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): applausetester+kh010901@applause.expensifail.com
Issue reported by: Applause Internal Team

Action Performed:

Precondition:

  • Rules and Workflows are enabled.
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Categories.
  3. Click on any category.
  4. Click Approver.
  5. Select any user.
  6. Click Name.
  7. Edit the name.

Expected Result:

Approver field will not go blank after editing category name.

Actual Result:

Approver field is blank for a moment after editing category name.

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • [x ] iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6604525_1726418206489.20240916_003344.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021837011004719364383
  • Upwork Job ID: 1837011004719364383
  • Last Price Increase: 2024-09-20
  • Automatic offers:
    • FitseTLT | Contributor | 104131224
Issue OwnerCurrent Issue Owner: @stephanieelliott

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 16, 2024
  2. melvin-bot commented on Sep 16, 2024

    @melvin-bot

    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.

  3. IuliiaHerets commented on Sep 16, 2024

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

  4. FitseTLT commented on Sep 16, 2024

    @FitseTLT
    Contributor

    Edited by proposal-police: This proposal was edited at 2024-09-16 19:47:51 UTC.

    Proposal

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

    Category rules - Approver field is blank for a moment after editing category name

    What is the root cause of that problem?

    We use category name to get the approver here

    const categoryApprover = CategoryUtils.getCategoryApprover(policy?.rules?.approvalRules ?? [], categoryName);

    but the policy rule takes time to get updated with the new category name

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

    We can use previous category name to get a fallback in case the approver with current category name doesn't exist

    const previousCategoryName = usePrevious(categoryName);
    
        const approverText = useMemo(() => {
            const categoryApprover = CategoryUtils.getCategoryApprover(policy?.rules?.approvalRules ?? [], categoryName);
            const prevApprover = CategoryUtils.getCategoryApprover(policy?.rules?.approvalRules ?? [], previousCategoryName);
            return categoryApprover ?? prevApprover ?? '';
        }, [categoryName, policy?.rules?.approvalRules]);
    

    We also have an option to use previousCategoryName policyCategories to achieve the same similar to what we did here

    const prev = Object.values(policyCategories ?? {}).find((category) => category.name === categoryName);
            const prevApprover = CategoryUtils.getCategoryApprover(policy?.rules?.approvalRules ?? [], prev?.previousCategoryName);
            return categoryApprover ?? prevApprover ?? '';
    

    BTW similar problem exists for default tax rate which depends on policy?.rules?.expenseRules here so similar fix can be done for it too.

    What alternative solutions did you explore? (Optional)

    The other option we have is update policy?.rules?.approvalRules optimistically in Category.renamePolicyCategory on category name change. We can iterate on the approvalRules and when we find applyWhen with value prop same as the oldname of the category we change that value with the new category name (we will also optimistically update policy?.rules?.expenseRules for the problem regarding default tax rate)

  5. FitseTLT commented on Sep 16, 2024

    @FitseTLT
    Contributor
  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 20, 2024
  7. changed the title [-]Category rules - Approver field is blank for a moment after editing category name[/-] [+][$250] Category rules - Approver field is blank for a moment after editing category name[/+] on Sep 20, 2024
  8. melvin-bot commented on Sep 20, 2024

    @melvin-bot
  9. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 20, 2024
  10. melvin-bot commented on Sep 20, 2024

    @melvin-bot

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

  11. 24 remaining items

  12. melvin-bot commented on Oct 3, 2024

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

    • [@thesahindia] The PR that introduced the bug has been identified. Link to the PR:
    • [@thesahindia] 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:
    • [@thesahindia] 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:
    • [@thesahindia] Determine if we should create a regression test for this bug.
    • [@thesahindia] 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.
    • [@stephanieelliott] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  13. stephanieelliott commented on Oct 11, 2024

    @stephanieelliott
    Contributor

    Hey @thesahindia can you complete the BugZero checklist please?

  14. stephanieelliott commented on Oct 11, 2024

    @stephanieelliott
    Contributor

    Summarizing payment on this issue:

    • Contributor: @FitseTLT $250 via Upwork - PAID
    • Contributor+: @thesahindia $250 via ND payments - please request!

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

  15. melvin-bot commented on Oct 14, 2024

    @melvin-bot

    @stephanieelliott, @FitseTLT, @stitesExpensify, @thesahindia Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  16. stephanieelliott commented on Oct 14, 2024

    @stephanieelliott
    Contributor

    Hey @thesahindia can you complete the BugZero checklist please?

    ^^ bump @thesahindia

  17. thesahindia commented on Oct 15, 2024

    @thesahindia
    Member

    Seems like it was an issue in the implementation.

    Here are the steps for the test case:

    Precondition: Taxes, Rules and Workflows are enabled.

    1. Go to workspace settings > Categories
    2. Select a category
    3. Click "Default tax rate"
    4. Choose any tax rate that differs from the default value
    5. Click "Approver"
    6. Choose a different user
    7. Click "Name"
    8. Change the name of the category > Save
    9. Verify that the default tax rate doesn't change
    10. Verify that the approver doesn't change
  18. stephanieelliott commented on Oct 16, 2024

    @stephanieelliott
    Contributor
  19. garrettmknight commented on Nov 26, 2024

    @garrettmknight
    Contributor

    $250 paid for @thesahindia

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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions