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] Category - Description hint field shows previous data after reenabling "Require description" #52399

Open
5 of 8 tasks
IuliiaHerets opened this issue Nov 12, 2024 · 7 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Nov 12, 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.60-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Y
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team

Action Performed:

Precondition:

  • Rules are enabled.
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Categories.
  3. Click on any category.
  4. Enable "Require description".
  5. Click Description hint.
  6. Enter anything and save it.
  7. Disable "Require description".
  8. Enable "Require description".
  9. Note that Description hint field is empty.
  10. Dismiss the RHP.
  11. Click on the same category.

Expected Result:

Description hint field will remain empty.

Actual Result:

Description hint field shows the previous data after reopening category settings.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6662259_1731402885400.20241112_171047.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021858724639436105772
  • Upwork Job ID: 1858724639436105772
  • Last Price Increase: 2024-11-19
Issue OwnerCurrent Issue Owner: @parasharrajat
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Nov 12, 2024
Copy link

melvin-bot bot commented Nov 12, 2024

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

@FitseTLT
Copy link
Contributor

Proposal

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

Category - Description hint field shows previous data after reenabling "Require description"

What is the root cause of that problem?

We are resetting the commentHint on disabling areCommentsRequired optimistically here

const updatedCommentHint = areCommentsRequired ? allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`]?.[categoryName]?.commentHint : '';

but we shouldn't as the BE is not resetting it (that's why you will see the commentHint you previously set if you re-open the category setting page before enabling areCommentsRequired again) and also as we already hide the commentHint menu when the comments required is disabled here
{!!policyCategory?.areCommentsRequired && (

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

We shouldn't reset commentHint just like the BE on disabling comment required. In setPolicyCategoryDescriptionRequired we should remove all the code that unnecessarily update commentHint of the policyCategory optimsitically.

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Nov 15, 2024
Copy link

melvin-bot bot commented Nov 18, 2024

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

@strepanier03
Copy link
Contributor

I was able to reproduce this and have tied it to a project. Setting external now.

@melvin-bot melvin-bot bot removed the Overdue label Nov 19, 2024
@strepanier03 strepanier03 added External Added to denote the issue can be worked on by a contributor Overdue labels Nov 19, 2024
@melvin-bot melvin-bot bot changed the title Category - Description hint field shows previous data after reenabling "Require description" [$250] Category - Description hint field shows previous data after reenabling "Require description" Nov 19, 2024
Copy link

melvin-bot bot commented Nov 19, 2024

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

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

melvin-bot bot commented Nov 19, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Nov 19, 2024
@huult
Copy link
Contributor

huult commented Nov 19, 2024

Edited by proposal-police: This proposal was edited at 2024-11-19 08:36:54 UTC.

Proposal

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

Description hint field shows previous data after reenabling "Require description"

What is the root cause of that problem?

When we toggle Require description to disable, we set commentHint to '', which is updated in Onyx to ''. That why, we can see Description hint was remove.

const updatedCommentHint = areCommentsRequired ? allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`]?.[categoryName]?.commentHint : '';

However, on the server, we do not update commentHint to ''. I say this because when we close the RHP and open it again, the OpenPolicyCategoriesPage is still able to retrieve the current value of commentHint.

  • Screenshot 2024-11-19 at 15 22 41

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

To resolve this issue, we must remove the description hint when we toggle Require description to disable, something like this:

//src/pages/workspace/categories/CategorySettingsPage.tsx#L245
         <Switch
            isOn={policyCategory?.areCommentsRequired ?? false}
            accessibilityLabel={translate('workspace.rules.categoryRules.requireDescription')}
+            onToggle={(isOn) => {
+                if (policyCategory.commentHint && !isOn) {
+                    Category.setWorkspaceCategoryDescriptionHint(policyID, categoryName, '');
+                }
                Category.setPolicyCategoryDescriptionRequired(policyID, categoryName, !areCommentsRequired);
            }}
        />

Test branch

POC
Screen.Recording.2024-11-19.at.15.28.19.mov

What alternative solutions did you explore? (Optional)

Or we can use areCommentsRequired to check when setting the workspace description hint

//src/pages/workspace/categories/CategorySettingsPage.tsx#L245
         <Switch
            isOn={policyCategory?.areCommentsRequired ?? false}
            accessibilityLabel={translate('workspace.rules.categoryRules.requireDescription')}
            onToggle={() => {
+                if (policyCategory.commentHint && areCommentsRequired) {
+                    Category.setWorkspaceCategoryDescriptionHint(policyID, categoryName, '');
+                }
                Category.setPolicyCategoryDescriptionRequired(policyID, categoryName, !areCommentsRequired);
            }}
        />

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. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
Status: No status
Development

No branches or pull requests

5 participants