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

[PAID] [$250] Distance rate- WS owner can create multiple distance rate with same amount #51769

Closed
2 of 8 tasks
lanitochka17 opened this issue Oct 30, 2024 · 46 comments
Closed
2 of 8 tasks
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 Reviewing Has a PR in review

Comments

@lanitochka17
Copy link

lanitochka17 commented Oct 30, 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.55-9
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): testpayment935+523@gmail.com
Issue reported by: Applause - Internal Team

Action Performed:

Preconditions
Navigate to http://www.staging.new.expensify.com/

  1. Create a new Workspace
  2. Navigate to workspace editor
  3. Navigate to "More features"
  4. Enable the distance rates toggle
    Steps
  5. Navigate to distance rates
  6. Click on "Add rate"
  7. Enter any rate that includes a decimal (e.g 2.2) and save
  8. Enter the same rate as step 3 and save

Expected Result:

Error shows as the rate is already exist

Actual Result:

WS owner can create multiple distance rate with same amount

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
Bug6650641_1730320405551.Screen_Recording_20241030_223334.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021854599760824128596
  • Upwork Job ID: 1854599760824128596
  • Last Price Increase: 2024-11-07
  • Automatic offers:
    • DylanDylann | Reviewer | 105060475
    • Krishna2323 | Contributor | 105060479
Issue OwnerCurrent Issue Owner: @strepanier03
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 30, 2024
Copy link

melvin-bot bot commented Oct 30, 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.

@lanitochka17
Copy link
Author

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

@Krishna2323
Copy link
Contributor

Krishna2323 commented Oct 30, 2024

Edited by proposal-police: This proposal was edited at 2024-10-30 21:07:32 UTC.

Proposal


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

Distance rate- WS owner can create multiple distance rate with same amount

What is the root cause of that problem?

  • In validateRateValue, we aren't checking for existing rate of the same amount.
    function validateRateValue(values: FormOnyxValues<RateValueForm>, currency: string, toLocaleDigit: (arg: string) => string): FormInputErrors<RateValueForm> {
    const errors: FormInputErrors<RateValueForm> = {};
    const parsedRate = MoneyRequestUtils.replaceAllDigits(values.rate, toLocaleDigit);
    const decimalSeparator = toLocaleDigit('.');
    // Allow one more decimal place for accuracy
    const rateValueRegex = RegExp(String.raw`^-?\d{0,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{0,${CONST.MAX_TAX_RATE_DECIMAL_PLACES}})?$`, 'i');
    if (!rateValueRegex.test(parsedRate) || parsedRate === '') {
    errors.rate = Localize.translateLocal('common.error.invalidRateError');
    } else if (NumberUtils.parseFloatAnyLocale(parsedRate) <= 0) {
    errors.rate = Localize.translateLocal('common.error.lowRateError');
    }
    return errors;
    }

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


  • In validateRateValue, we should start accepting customUnitRates.
  • Check for existing rate in customUnitRates of the same amount and return an error.
    const rateValueRegex = RegExp(String.raw`^-?\d{0,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{0,${CONST.MAX_TAX_RATE_DECIMAL_PLACES}})?$`, 'i');
    const ratesList = Object.values(customUnitRates);
    if (ratesList.some((r) => r.rate === convertToBackendAmount(Number(parsedRate)))) {
        errors.rate = Localize.translateLocal('common.error.invalidRateError');
    } else if (!rateValueRegex.test(parsedRate) || parsedRate === '') {
        errors.rate = Localize.translateLocal('common.error.invalidRateError');
    } else if (NumberUtils.parseFloatAnyLocale(parsedRate) <= 0) {
        errors.rate = Localize.translateLocal('common.error.lowRateError');
    }
    return errors;
  • Pass customUnitRates to validateRateValue from CreateDistanceRatePage & PolicyDistanceRateEditPage.
    const customUnitRates: Record<string, Rate> = useMemo(() => customUnit?.rates ?? {}, [customUnit]);
    
    const validate = useCallback(
        (values: FormOnyxValues<typeof ONYXKEYS.FORMS.POLICY_CREATE_DISTANCE_RATE_FORM>) => {
            return validateRateValue(values, currency, toLocaleDigit, customUnitRates);
        },
        [currency, toLocaleDigit, customUnitRates],
    );
  • We should create new error translation for duplicate rate.

What alternative solutions did you explore? (Optional)

Result

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

melvin-bot bot commented Nov 5, 2024

@strepanier03 Huh... This is 4 days overdue. Who can take care of this?

@strepanier03
Copy link
Contributor

We chatted about this internally, and we want to block duplicate rates since the rate is the name and it's not possible to differentiate. We also block categories and tags of the same name so we'd want this similar to that.

@melvin-bot melvin-bot bot removed the Overdue label Nov 7, 2024
@strepanier03 strepanier03 added the External Added to denote the issue can be worked on by a contributor label Nov 7, 2024
@melvin-bot melvin-bot bot changed the title Distance rate- WS owner can create multiple distance rate with same amount [$250] Distance rate- WS owner can create multiple distance rate with same amount Nov 7, 2024
Copy link

melvin-bot bot commented Nov 7, 2024

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

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

melvin-bot bot commented Nov 7, 2024

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

@strepanier03
Copy link
Contributor

Working on determining the project now.

@strepanier03
Copy link
Contributor

We are unlikely to make any changes to this other than blocking the duplicate rate, but we will in the future most likely.

@strepanier03

This comment was marked as outdated.

@strepanier03 strepanier03 changed the title [$250] Distance rate- WS owner can create multiple distance rate with same amount [HOLD] [$250] Distance rate- WS owner can create multiple distance rate with same amount Nov 7, 2024
@strepanier03
Copy link
Contributor

Okay, we are good to move forward, here is the outcome.

  • we should not be allowing duplicate rates in the same workspace
  • separately (and less important IMO but still worth fixing) we should not show any rate names in the rate selection screen

Let's focus on not allowing duplicate rates within the same workspace in this GH and the other issue will be handled separately.

@DylanDylann
Copy link
Contributor

@Krishna2323's proposal looks good to me

🎀 👀 🎀 C+ Reviewed

Copy link

melvin-bot bot commented Nov 11, 2024

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

@DylanDylann
Copy link
Contributor

@bondydaa Friendly bump

@DylanDylann
Copy link
Contributor

@strepanier03 It seems @bondydaa is OOO

Screenshot 2024-11-14 at 11 54 57

@DylanDylann
Copy link
Contributor

@strepanier03 as mentioned here, @bondydaa is left and we need a new engineer to process this one. Could you help to unassign @bondydaa?

@bondydaa bondydaa removed their assignment Nov 18, 2024
@melvin-bot melvin-bot bot added the Awaiting Payment Auto-added when associated PR is deployed to production label Dec 4, 2024
@melvin-bot melvin-bot bot changed the title [$250] Distance rate- WS owner can create multiple distance rate with same amount [HOLD for payment 2024-12-11] [$250] Distance rate- WS owner can create multiple distance rate with same amount Dec 4, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Dec 4, 2024
Copy link

melvin-bot bot commented Dec 4, 2024

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

Copy link

melvin-bot bot commented Dec 4, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.70-9 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-12-11. 🎊

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

Copy link

melvin-bot bot commented Dec 4, 2024

@DylanDylann @strepanier03 @DylanDylann 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 Reviewing Has a PR in review Weekly KSv2 Daily KSv2 and removed Weekly KSv2 labels Dec 4, 2024
@garrettmknight garrettmknight moved this from Bugs and Follow Up Issues to Hold for Payment in [#whatsnext] #expense Dec 10, 2024
Copy link

melvin-bot bot commented Dec 17, 2024

@danieldoglas, @strepanier03, @Krishna2323, @DylanDylann Whoops! This issue is 2 days overdue. Let's get this updated quick!

@danieldoglas
Copy link
Contributor

@strepanier03 I think this is ready for payment.

Copy link

melvin-bot bot commented Dec 19, 2024

@danieldoglas, @strepanier03, @Krishna2323, @DylanDylann Huh... This is 4 days overdue. Who can take care of this?

@strepanier03
Copy link
Contributor

My apologies all, I was out for my anniversary and then got really sick. I'm taking care of this now.

@strepanier03
Copy link
Contributor

@DylanDylann can you please finish the checklist mentioned here? I can't pay out your contract until it's complete.

@strepanier03
Copy link
Contributor

strepanier03 commented Dec 19, 2024

Payment summary

@strepanier03
Copy link
Contributor

@Krishna2323 - I've paid and closed your contract in Upwork.

@strepanier03 strepanier03 changed the title [HOLD for payment 2024-12-11] [$250] Distance rate- WS owner can create multiple distance rate with same amount [Payment 2024-12-11] [$250] Distance rate- WS owner can create multiple distance rate with same amount Dec 19, 2024
@DylanDylann
Copy link
Contributor

DylanDylann commented Dec 20, 2024

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other:

Where bug was reported:

  • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
  • 2b. Reported on staging (eg. found during regression or PR testing)
  • 2d. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [Contributor] 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: feat: policy add distance rate #38035 (comment)

  • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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:

  • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

  • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

    Link to issue:

Regression Test Proposal

Precondition:

Test:

  1. Open a workspace
  2. Navigate to "More features"
  3. Enable the distance rates
  4. Navigate to distance rates
  5. Click on "Add rate" > Enter any rate and save
  6. Click on "Add rate" > Enter the same rate added in the previous step
  7. Click "Save" > Verify that the error message is shown A rate with value ${rate} already exists.
  8. Create a new rate with a different value
  9. Edit the new rate > Enter the same rate added in step 5
  10. Verify error message is shown A rate with value ${rate} already exists.

Do we agree 👍 or 👎

Copy link

melvin-bot bot commented Dec 27, 2024

@danieldoglas, @strepanier03, @Krishna2323, @DylanDylann Whoops! This issue is 2 days overdue. Let's get this updated quick!

Copy link

melvin-bot bot commented Dec 31, 2024

@danieldoglas, @strepanier03, @Krishna2323, @DylanDylann 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

@danieldoglas
Copy link
Contributor

@Krishna2323 is this paid? Can we close it?

Copy link

melvin-bot bot commented Jan 2, 2025

@danieldoglas, @strepanier03, @Krishna2323, @DylanDylann Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

@strepanier03
Copy link
Contributor

Back from OoO. I've payed and closed the contract in Upwork for @DylanDylann and made the reg test. This is ready to close now. Thanks everyone!

@github-project-automation github-project-automation bot moved this from Hold for Payment to Done in [#whatsnext] #expense Jan 3, 2025
@strepanier03 strepanier03 changed the title [Payment 2024-12-11] [$250] Distance rate- WS owner can create multiple distance rate with same amount [PAID] [$250] Distance rate- WS owner can create multiple distance rate with same amount Jan 3, 2025
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 Reviewing Has a PR in review
Projects
Status: Done
Development

No branches or pull requests

10 participants