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

[HOLD for payment 2024-11-29] [$250] Tax - Enable/disable option shows rates text in plural instead rate #51017

Closed
8 tasks
lanitochka17 opened this issue Oct 17, 2024 · 54 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Oct 17, 2024

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.50-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/home
  2. Tap profile icon - workspaces -- workspace
  3. Tap more features - enable taxes
  4. Create few tax rates
  5. Disable a tax rate
  6. Long press and select one disabled and one enabled tax rate
  7. Tap dropdown on top and view options

Expected Result:

Enable/disable option must not show rates text in plural and it must show rate

Actual Result:

Enable/disable option shows rates text in plural instead rate when only one enabled and disabled rate are selected

Workaround:

Unknown

Platforms:

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

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

Screenshots/Videos

Add any screenshot/video evidence
Bug6637276_1729142094339.rate.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021846961178055724837
  • Upwork Job ID: 1846961178055724837
  • Last Price Increase: 2024-11-07
Issue OwnerCurrent Issue Owner: @getusha
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 17, 2024
Copy link

melvin-bot bot commented Oct 17, 2024

Triggered auto assignment to @isabelastisser (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
Copy link
Author

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

Copy link
Contributor

rzghnsy Your proposal will be dismissed because you did not follow the proposal template.

@nyomanjyotisa
Copy link
Contributor

nyomanjyotisa commented Oct 17, 2024

Edited by proposal-police: This proposal was edited at 2024-10-17 13:37:10 UTC.

Proposal

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

Tax - Enable/disable option shows rates text in plural instead rate

What is the root cause of that problem?

We show plural text base on isMultiple variable, without checking the enable/disable status of the selected tax

const isMultiple = selectedTaxesIDs.length > 1;

text: isMultiple ? translate('workspace.taxes.actions.disableMultiple') : translate('workspace.taxes.actions.disable'),

text: isMultiple ? translate('workspace.taxes.actions.enableMultiple') : translate('workspace.taxes.actions.enable'),

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

Create new variables to check is there multiple enabled tax selected and is there multiple disabled tax selected

        const isMultipleEnabled = selectedTaxesIDs.filter((taxID) => !policy?.taxRates?.taxes[taxID]?.isDisabled).length > 1;
        const isMultipleDisabled = selectedTaxesIDs.filter((taxID) => policy?.taxRates?.taxes[taxID]?.isDisabled).length > 1;
// `Disable rates` when at least one enabled rate is selected.
        if (selectedTaxesIDs.some((taxID) => !policy?.taxRates?.taxes[taxID]?.isDisabled)) {
            options.push({
                icon: Expensicons.DocumentSlash,
                text: isMultipleEnabled ? translate('workspace.taxes.actions.disableMultiple') : translate('workspace.taxes.actions.disable'),
                value: CONST.POLICY.BULK_ACTION_TYPES.DISABLE,
                onSelected: () => toggleTaxes(false),
            });
        }

        // `Enable rates` when at least one disabled rate is selected.
        if (selectedTaxesIDs.some((taxID) => policy?.taxRates?.taxes[taxID]?.isDisabled)) {
            options.push({
                icon: Expensicons.Document,
                text: isMultipleDisabled ? translate('workspace.taxes.actions.enableMultiple') : translate('workspace.taxes.actions.enable'),
                value: CONST.POLICY.BULK_ACTION_TYPES.ENABLE,
                onSelected: () => toggleTaxes(true),
            });
        }

What alternative solutions did you explore? (Optional)

@Nodebrute
Copy link
Contributor

Proposal

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

Enable/disable option shows rates text in plural instead rate

What is the root cause of that problem?

Here we only see if selected tags are more than 1 instead of checking disable/enable tags count

const isMultiple = selectedTaxesIDs.length > 1;

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

We can create 2 new variables

        const disableTaxes = selectedTaxesIDs.filter((taxID) => policy?.taxRates?.taxes[taxID]?.isDisabled);
        const enabledTaxes = selectedTaxesIDs.filter((taxID) => !policy?.taxRates?.taxes[taxID]?.isDisabled);

and then in here we can check

   if (disableTaxes.length > 0)

and in here we can change this to

 text: disableTaxes.length === 1 ?  translate('workspace.taxes.actions.disable') : translate('workspace.taxes.actions.disableMultiple'),

We can do same for enable tags

What alternative solutions did you explore? (Optional)

@ChavdaSachin
Copy link
Contributor

ChavdaSachin commented Oct 17, 2024

Edited by proposal-police: This proposal was edited at 2024-10-17 13:57:28 UTC.

Proposal

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

Tax - Enable/disable option shows rates text in plural instead rate

What is the root cause of that problem?

Irrespective of number of available rates to enable/disable, we check only for number of selections here.

const isMultiple = selectedTaxesIDs.length > 1;

text: isMultiple ? translate('workspace.taxes.actions.disableMultiple') : translate('workspace.taxes.actions.disable'),

text: isMultiple ? translate('workspace.taxes.actions.enableMultiple') : translate('workspace.taxes.actions.enable'),

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

Rather create new objects enabledRates and disabledRates

        const enbledRates = selectedTaxesIDs.filter((taxID) => policy?.taxRates?.taxes[taxID]?.isDisabled);
        const disabledRates = selectedTaxesIDs.filter((taxID) => !policy?.taxRates?.taxes[taxID]?.isDisabled);

now use enabledRates?.length here to saw the option

        if (enabledRates?.length) {

if (selectedTaxesIDs.some((taxID) => !policy?.taxRates?.taxes[taxID]?.isDisabled)) {

and use enabledRates?.length > 1 instead of isMultiple here
text: isMultiple ? translate('workspace.taxes.actions.disableMultiple') : translate('workspace.taxes.actions.disable'),

Similar for Enable option use 'disabledRates?.length' here.

        if (disabledRates?.length) {

if (selectedTaxesIDs.some((taxID) => policy?.taxRates?.taxes[taxID]?.isDisabled)) {

And use disabledRates?.length > 1 instead of isMultiple here.
text: isMultiple ? translate('workspace.taxes.actions.enableMultiple') : translate('workspace.taxes.actions.enable'),

This way we optimize the solution and do not have to filter array twice.

What alternative solutions did you explore? (Optional)

And since we make use of this logic only to determine length of selections, we could optimize it further.

Only create 1 object which holds count of enabled selections and use it to determine length of disabledSelectionCount.

        const enabledRatesCount = selectedTaxesIDs.filter((taxID) => !policy?.taxRates?.taxes[taxID]?.isDisabled).length;
        const disabledRatesCount = selectedTaxesIDs.length - enabledRatesCount;

and use those variables for check here

if (selectedTaxesIDs.some((taxID) => !policy?.taxRates?.taxes[taxID]?.isDisabled)) {

text: isMultiple ? translate('workspace.taxes.actions.disableMultiple') : translate('workspace.taxes.actions.disable'),

if (selectedTaxesIDs.some((taxID) => policy?.taxRates?.taxes[taxID]?.isDisabled)) {

text: isMultiple ? translate('workspace.taxes.actions.enableMultiple') : translate('workspace.taxes.actions.enable'),

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@ChavdaSachin
Copy link
Contributor

Updated Proposal
Added perfectly optimized way to solve the issue as alternate solution.

@twilight2294
Copy link
Contributor

Proposal

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

Enable/disable option shows rates text in plural instead rate

What is the root cause of that problem?

We check if multiple are selected:

const isMultiple = selectedTaxesIDs.length > 1;

If so then without checking if there are multiple selected or not, we directly show plural form of texts:

text: isMultiple ? translate('workspace.taxes.actions.disableMultiple') : translate('workspace.taxes.actions.disable'),

text: isMultiple ? translate('workspace.taxes.actions.enableMultiple') : translate('workspace.taxes.actions.enable'),

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

First we need to get the disabled and enabled taxes:

        const enabledRatesCount = selectedTaxesIDs.filter((taxID) => !policy?.taxRates?.taxes[taxID]?.isDisabled).length;
        const disabledRatesCount = selectedTaxesIDs.length - enabledRatesCount;

Now according to our Readme:

Here’s an example of how to implement plural translations:

messages: () => ({ zero: 'No messages', one: 'One message', two: 'Two messages', few: (count) => ${count} messages, many: (count) => You have ${count} messages, other: (count) => You have ${count} unread messages, })

So we should not do condition rendering here, instead we should update the text to match this plural forms:

First update the en.ts and es.ts file to unify the multi tags messages:

           disableTaxTitle: () => ({
                one: 'Disable rate',
                other: 'Disable rates',
            }),
            enableTaxTitle: () => ({
                one: 'enable rate',
                other: 'enable rates',
            }),
            
        // `Disable rates` when at least one enabled rate is selected.
        if (selectedTaxesIDs.some((taxID) => !policy?.taxRates?.taxes[taxID]?.isDisabled)) {
            options.push({
                icon: Expensicons.DocumentSlash,
                text: translate('workspace.taxes.actions.disableTaxTitle', {count: disabledRatesCount}),
                value: CONST.POLICY.BULK_ACTION_TYPES.DISABLE,
                onSelected: () => toggleTaxes(false),
            });
        }

        // `Enable rates` when at least one disabled rate is selected.
        if (selectedTaxesIDs.some((taxID) => policy?.taxRates?.taxes[taxID]?.isDisabled)) {
            options.push({
                icon: Expensicons.Document,
                text: translate('workspace.taxes.actions.enableTaxTitle', {count: enabledRatesCount}),
                value: CONST.POLICY.BULK_ACTION_TYPES.ENABLE,
                onSelected: () => toggleTaxes(true),
            });
        }

We can even optimise the conditions during PR phase

What alternative solutions did you explore? (Optional)

@isabelastisser isabelastisser added 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 labels Oct 17, 2024
@melvin-bot melvin-bot bot changed the title Tax - Enable/disable option shows rates text in plural instead rate [$250] Tax - Enable/disable option shows rates text in plural instead rate Oct 17, 2024
Copy link

melvin-bot bot commented Oct 17, 2024

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

Copy link

melvin-bot bot commented Oct 17, 2024

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

Copy link

melvin-bot bot commented Oct 22, 2024

@isabelastisser, @getusha Huh... This is 4 days overdue. Who can take care of this?

@melvin-bot melvin-bot bot added the Overdue label Oct 22, 2024
@isabelastisser
Copy link
Contributor

@getusha, can you please review the proposals above and provide an update? Thanks!

@isabelastisser
Copy link
Contributor

Bump @getusha for an update, thanks!

@getusha
Copy link
Contributor

getusha commented Oct 24, 2024

Reviewing

@melvin-bot melvin-bot bot removed the Overdue label Oct 24, 2024
@getusha
Copy link
Contributor

getusha commented Oct 24, 2024

there are 3 cases we need to handle

1 disabled
1 enabled rate
- Disable rate
- Enable rate

1 disabled
2 enabled rate
- Disable rates
- Enable rate

2 disabled
1 enabled
- Disable rate
- Enable rates

Copy link

melvin-bot bot commented Oct 24, 2024

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

@getusha
Copy link
Contributor

getusha commented Oct 24, 2024

Not sure if this is worth fixing though @techievivek what do you think?

@twilight2294
Copy link
Contributor

Not sure if this is worth fixing though @techievivek what do you think?

@getusha , this is supposed to be fixed, we recently fixed a similar issue on members page as well:

c.c. @techievivek

Copy link

melvin-bot bot commented Oct 24, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@isabelastisser
Copy link
Contributor

@twilight2294 @getusha, to clarify, is this issue fixed?

#51017 (comment)

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

melvin-bot bot commented Nov 13, 2024

📣 @twilight2294 You have been assigned to this job!
Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs!
Keep in mind: Code of Conduct | Contributing 📖

@twilight2294
Copy link
Contributor

I applied for the job on upwork, PR will be ready in few hours

@twilight2294
Copy link
Contributor

PR ready for review c.c. @getusha

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Nov 22, 2024
@melvin-bot melvin-bot bot changed the title [$250] Tax - Enable/disable option shows rates text in plural instead rate [HOLD for payment 2024-11-29] [$250] Tax - Enable/disable option shows rates text in plural instead rate Nov 22, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 22, 2024
Copy link

melvin-bot bot commented Nov 22, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Nov 22, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.65-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-11-29. 🎊

For reference, here are some details about the assignees on this issue:

  • @getusha requires payment through NewDot Manual Requests
  • @twilight2294 requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented Nov 22, 2024

@getusha @isabelastisser @getusha The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Nov 29, 2024
Copy link

melvin-bot bot commented Nov 29, 2024

Payment Summary

Upwork Job

BugZero Checklist (@isabelastisser)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1846961178055724837/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@melvin-bot melvin-bot bot added the Overdue label Dec 2, 2024
Copy link

melvin-bot bot commented Dec 2, 2024

@isabelastisser, @techievivek, @getusha, @twilight2294 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@twilight2294
Copy link
Contributor

@isabelastisser can you pay me for this issue ?

@isabelastisser
Copy link
Contributor

I was OOO last week, I will review this today.

@isabelastisser
Copy link
Contributor

@getusha, do we need a regression test?

@isabelastisser
Copy link
Contributor

isabelastisser commented Dec 2, 2024

Payment summary:

Reviewer: @getusha owed $250 via NewDot C+ PENDING
Contributor/ Proposal: @twilight2294 paid $250 via Upwork (LINK)

@isabelastisser
Copy link
Contributor

@getusha confirmed via DM that we don't need a regression test. all set!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
Development

No branches or pull requests

8 participants