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

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

Closed
6 tasks done
lanitochka17 opened this issue Oct 25, 2023 · 21 comments
Closed
6 tasks done
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 Reviewing Has a PR in review

Comments

@lanitochka17
Copy link

lanitochka17 commented Oct 25, 2023

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
@lanitochka17 lanitochka17 added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 25, 2023
@melvin-bot melvin-bot bot 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 Oct 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 25, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 25, 2023

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 25, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 25, 2023

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

@GItGudRatio
Copy link
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

@Samueljh1
Copy link
Contributor

Samueljh1 commented Oct 25, 2023

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

@tienifr
Copy link
Contributor

tienifr commented Oct 26, 2023

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

@DylanDylann
Copy link
Contributor

DylanDylann commented Oct 26, 2023

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)

@johncschuster
Copy link
Contributor

@robertKozik it looks like we've got a few proposals above. Can you take a look?

@robertKozik
Copy link
Contributor

Sure, I'm on it.
Thank you all for your proposals. After carefully looking into all proposals I believe we should go with the @tienifr proposal. It was the first to correctly state the root cause of the problem and the solution was detailed enough in my opinion.

I believe we should go with the @tienifr proposal

@melvin-bot melvin-bot bot added the Overdue label Oct 30, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 30, 2023

@johncschuster, @robertKozik Whoops! This issue is 2 days overdue. Let's get this updated quick!

@robertKozik
Copy link
Contributor

eh... forgot the precious line:
🎀 👀 🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Oct 31, 2023

Triggered auto assignment to @johnmlee101, 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 Oct 31, 2023
Copy link

melvin-bot bot commented Oct 31, 2023

📣 @tienifr 🎉 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 📖

@puneetlath puneetlath changed the title [$500] Tag - Unable to unselect tag from created expense when the tag is disabled [$500] [Wave 6: Tags] - Unable to unselect tag from created expense when the tag is disabled Nov 9, 2023
Copy link

melvin-bot bot commented Nov 21, 2023

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Nov 21, 2023
@mountiny
Copy link
Contributor

mountiny commented Dec 7, 2023

@tienifr @robertKozik Whats the status of this issue? has there been any regressions?

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Dec 15, 2023
Copy link

melvin-bot bot commented Dec 15, 2023

This issue has not been updated in over 15 days. @johnmlee101, @johncschuster, @robertKozik, @tienifr eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@johncschuster johncschuster added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Dec 15, 2023
@melvin-bot melvin-bot bot added Daily KSv2 and removed Monthly KSv2 labels Dec 15, 2023
@Expensify Expensify deleted a comment from melvin-bot bot Dec 15, 2023
@Expensify Expensify deleted a comment from melvin-bot bot Dec 15, 2023
@johncschuster johncschuster removed their assignment Dec 15, 2023
@johncschuster johncschuster added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Dec 15, 2023
Copy link

melvin-bot bot commented Dec 15, 2023

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

@johncschuster
Copy link
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!

@Expensify Expensify deleted a comment from melvin-bot bot Dec 15, 2023
@johncschuster johncschuster self-assigned this Dec 15, 2023
@robertKozik
Copy link
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

@slafortune
Copy link
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
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 Reviewing Has a PR in review
Projects
No open projects
Development

No branches or pull requests

10 participants