Skip to content

[$500] [Wave 6: Tags] - Unable to unselect tag from created expense when the tag is disabled #30380

Closed

Description

@lanitochka17

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.3.91-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Go to staging.new.expensify.com
  2. As employee, create a workspace expense with a tag
  3. As admin, go to OD and disable the tag created in Step 1
  4. As employee, go to the workspace expense details page and refresh the page
  5. Click on Tag

Expected Result:

User is able to unselect the tag

Actual Result:

User is unable to unselect the tag. It is disabled

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • Windows: Chrome
  • MacOS: Desktop

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
Windows: Chrome
Bug6250597_1698253971783.bandicam_2023-10-25_19-21-42-699.mp4
MacOS: Desktop

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01dfd87fd1cc34a215
  • Upwork Job ID: 1717255074756784128
  • Last Price Increase: 2023-10-25
  • Automatic offers:
    • tienifr | Contributor | 27458232

Activity

  1. added
    External
    Daily
    Bug
    on Oct 25, 2023
  2. changed the title [-]Tag - Unable to unselect tag from created expense when the tag is disabled[/-] [+][$500] Tag - Unable to unselect tag from created expense when the tag is disabled[/+] on Oct 25, 2023
  3. melvin-bot commented on Oct 25, 2023

    @melvin-bot
  4. melvin-bot commented on Oct 25, 2023

    @melvin-bot

    Triggered auto assignment to @johncschuster (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  5. added
    Help Wanted
    on Oct 25, 2023
  6. melvin-bot commented on Oct 25, 2023

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  7. melvin-bot commented on Oct 25, 2023

    @melvin-bot

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

  8. GItGudRatio commented on Oct 25, 2023

    @GItGudRatio
    Contributor

    Weirdly enough, while trying to re create this issue, the tag itself disappears completely for me. It's not present in the list at all

    image
  9. Samueljh1 commented on Oct 25, 2023

    @Samueljh1
    Contributor

    Proposal

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

    Unable to unselect a previously set tag after it has been disabled by an admin.

    What is the root cause of that problem?

    The OptionsSelector disables interaction for all tags that have been switched off by a workspace admin. Although this is appropriate behaviour for a tag that is not selected, we should still let the user remove the tag.

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

    We need to make an exception in the TagPicker component to allow an already selected tag to be removed regardless of its state. This way, the user can deselect it (while preventing it from being selected again).

    We can read the value of the selectedOptions array in TagPicker to do this. For these tags, we ensure that they are enabled in the OptionsSelector.

    What alternative solutions did you explore? (Optional)

    N/A

  10. tienifr commented on Oct 26, 2023

    @tienifr
    Contributor

    Proposal

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

    Tag - Unable to unselect tag from created expense when the tag is disabled

    What is the root cause of that problem?

    When the tag is disabled, we don't show it in option list

    const enabledTags = _.filter(tags, (tag) => tag.enabled);

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

    Because we use TagPicker in many places, so we should define the new props for TagPicker like shouldShowDisabledAndSelectedOption and just enable it in EditRequestTagPage

    In TagPicker, if shouldShowDisabledAndSelectedOption is true, we can get the enabledTags by merging 2 arrays: selectedOptions and policyTagList (remove the duplicate option)

    Here's the sample code:

        const selectedNames = selectedOptions.map(s=>s.name)
        const enabledTags = [...selectedOptions,..._.filter(policyTagList, (tag) => (tag.enabled && !selectedNames.includes(tag.name)))]
    

    then pass enabledTags to getFilteredOptions function

    What alternative solutions did you explore? (Optional)

    In the case we're creating the new request and select the enabled tag. But at that time, admin disable this tag, we should clear the tag in the in-processing request

    Result

    Screen.Recording.2023-10-26.at.11.39.13.mov
  11. DylanDylann commented on Oct 26, 2023

    @DylanDylann
    Contributor

    Proposal

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

    If we disable selected tag, this tag will hide in Tag list

    What is the root cause of that problem?

    Let's see the logic to get tags

    if (numberOfTags < CONST.TAG_LIST_THRESHOLD) {

    If numberOfTag < 8, we return all enable tags (only enable tags)

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

    we should move this code

    if (!_.isEmpty(selectedOptions)) {
    const selectedTagOptions = _.map(selectedOptions, (option) => {
    const tagObject = _.find(tags, (tag) => tag.name === option.name);
    return {
    name: option.name,
    enabled: Boolean(tagObject && tagObject.enabled),
    };
    });
    tagSections.push({
    // "Selected" section
    title: '',
    shouldShow: false,
    indexOffset,
    data: getTagsOptions(selectedTagOptions),
    });
    indexOffset += selectedOptions.length;
    }

    to before

    if (numberOfTags < CONST.TAG_LIST_THRESHOLD) {

    and in here

    data: getTagsOptions(enabledTags),

    update to

                data: getTagsOptions(lodashDifferenceBy(enabledTags, selectedOptions, 'name')),
    
    

    to avoid dupe the selected tag.

    With this approach we also need to update

    const initialFocusedIndex = useMemo(() => {

    like we did in CategoryPicker

    What alternative solutions did you explore? (Optional)

  12. 28 remaining items

  13. deleted a comment from melvin-bot on Dec 15, 2023
  14. deleted a comment from melvin-bot on Dec 15, 2023
  15. removed their assignment
    on Dec 15, 2023
  16. added
    Bug
    and removed
    Bug
    on Dec 15, 2023
  17. melvin-bot commented on Dec 15, 2023

    @melvin-bot

    Triggered auto assignment to @slafortune (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  18. johncschuster commented on Dec 15, 2023

    @johncschuster
    Contributor

    I will be OOO starting Monday, December 18, and will return Tuesday, January 2.

    Current status:
    We're waiting on an overall status from @tienifr / @robertKozik
    Payment has not been issued
    Regression steps have not been proposed (if applicable)

    If this issue is open when I'm back from OOO, I'll take it back over. Thank you!

  19. deleted a comment from melvin-bot on Dec 15, 2023
  20. robertKozik commented on Dec 18, 2023

    @robertKozik
    Contributor

    Hey! PR for this issue caused one regression which was handled as different task by the time of merge (here but overally the issue should be resolved already.

    As for the regression steps, I think we can propose them here:

    1. As employee, create a workspace expense with a tag
    2. As admin, go to OD and disable the tag created in Step 1
    3. As employee, go to the workspace expense details page and refresh the page
    4. Click on Tag
    5. Verify that user is able to unselect the tag
  21. slafortune commented on Dec 18, 2023

    @slafortune
    Contributor

    Thanks for the update!
    Test GH created - https://github.com/Expensify/Expensify/issues/351737
    Paid @tienifr
    @robertKozik part of Software Mansion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugDailyExternalReviewing

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions