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 2023-09-04] [$1000] Reimburse - 0.5 is allowed, but .5 is not allowed #25514

Closed
2 of 6 tasks
lanitochka17 opened this issue Aug 18, 2023 · 36 comments
Closed
2 of 6 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

Comments

@lanitochka17
Copy link

lanitochka17 commented Aug 18, 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!


Action Performed:

  1. Go to reimbursement
  2. Track distance
  3. Go inside rate per mile
  4. Change rate to 0.5 click save, it’s accepted
  5. Change rate to .5 click save, it throws validation error

Expected Result:

.5 is valid rate, should not throw error

Actual Result:

Throws error

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Chrome
  • Windows / Chrome
  • MacOS / Desktop

Version Number: 1.3.55-7

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

Notes/Photos/Videos: Any additional supporting documentation

RPReplay_Final1691592659.1.MP4
Desktop.2023.08.18.-.17.10.07.01.1.mp4

Expensify/Expensify Issue URL:

Issue reported by: @Premsjce

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1691592935896589

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01db7922b3ba7a8491
  • Upwork Job ID: 1693978352051523584
  • Last Price Increase: 2023-08-22
  • Automatic offers:
    • cubuspl42 | Reviewer | 26272077
    • GItGudRatio | Contributor | 26272078
@GItGudRatio
Copy link
Contributor

Proposal

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

0.5 is allowed, but .5 is not allowed in the rate field.

What is the root cause of that problem?

In the regex used, we explicitly ask for at least one digit to be present on the left side of the decimal. Thus, we cannot use .5.

const rateValueRegex = RegExp(String.raw`^\d{1,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{1,3})?$`, 'i');

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

We should change the regex to be this to ensure that if there is no digit on the left hand side, it automatically counts as 0:
^\d{0,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{1,3})?$.

Having this change wouldn't impact the server as we already add the 0 to the left of the decimal here:

const rateNumValue = this.getNumericValue(rate);

What alternative solutions did you explore? (Optional)

N/A

@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 18, 2023
@dukenv0307
Copy link
Contributor

Proposal

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

0.5 is allowed, but .5 is not allowed

What is the root cause of that problem?

We use this regex to validate the rate and It does not allow before the dot without any number

const rateValueRegex = RegExp(String.raw`^\d{1,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{1,3})?$`, 'i');
if (!rateValueRegex.test(values.rate)) {

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

We should change the regex to allow the rate that doesn't contain digit before the dot

const rateValueRegex = RegExp(String.raw`^\d{0,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{1,3})?$`, 'i');
if (!rateValueRegex.test(values.rate) || _.isEmpty(values.rate)) {
    errors.rate = 'workspace.reimburse.invalidRateError';
}

const rateValueRegex = RegExp(String.raw`^\d{1,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{1,3})?$`, 'i');
if (!rateValueRegex.test(values.rate)) {

What alternative solutions did you explore? (Optional)

@melvin-bot
Copy link

melvin-bot bot commented Aug 18, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 18, 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

@rayane-djouah
Copy link
Contributor

rayane-djouah commented Aug 18, 2023

Proposal

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

When entering a rate for reimbursement, the value "0.5" is accepted, but ".5" is not. The system throws a validation error for ".5", even though it should be considered a valid rate.

What is the root cause of that problem?

The root cause is the regular expression used for validation in the WorkspaceRateAndUnitPage.js file. The current regex expects at least one digit before the decimal separator, which is why ".5" is not considered valid.

validate(values) {
const errors = {};
const decimalSeparator = this.props.toLocaleDigit('.');
const rateValueRegex = RegExp(String.raw`^\d{1,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{1,3})?$`, 'i');
if (!rateValueRegex.test(values.rate)) {
errors.rate = 'workspace.reimburse.invalidRateError';
}
return errors;
}

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

We need to modify the regex to allow for values that don't have a digit before the decimal separator. The updated regex should be:

const rateValueRegex = RegExp(String.raw`^(\d{0,8}[${getPermittedDecimalSeparator(decimalSeparator)}]\d{1,3})?$`, 'i');

This change will ensure that both ".5" and "0.5" are considered valid rate values.

Result:

2023-08-18.23-05-52.mp4

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Aug 21, 2023
@ShogunFire
Copy link
Contributor

ShogunFire commented Aug 21, 2023

Is that really a bug, it's a bit different but when we did that page they said saving 1. was an issue

#19685

@melvin-bot
Copy link

melvin-bot bot commented Aug 22, 2023

@bfitzexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@bfitzexpensify
Copy link
Contributor

Is that really a bug, it's a bit different but when we did that page they said saving 1. was an issue

To me, 1. is an invalid number, since I couldn't say reliably what it was meant to be. It's reasonable to type .5 since it's reasonably obvious that it means 0.5

@melvin-bot melvin-bot bot removed the Overdue label Aug 22, 2023
@bfitzexpensify bfitzexpensify added the External Added to denote the issue can be worked on by a contributor label Aug 22, 2023
@melvin-bot melvin-bot bot changed the title Reimburse - 0.5 is allowed, but .5 is not allowed [$1000] Reimburse - 0.5 is allowed, but .5 is not allowed Aug 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 22, 2023

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

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

melvin-bot bot commented Aug 22, 2023

Triggered auto assignment to @conorpendergrast (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Aug 22, 2023

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

@bfitzexpensify
Copy link
Contributor

@cubuspl42 we have a couple of proposals already ready for review when you get a chance - thanks!

@conorpendergrast I'm heading ooo for a week, will leave myself assigned and can take this back over upon my return

@cubuspl42
Copy link
Contributor

cubuspl42 commented Aug 22, 2023

The proposal by @GItGudRatio seems to solve the problem cleanly and their bot was the fastest. Other proposals look similar.

C+ reviewed 🎀 👀 🎀

@melvin-bot
Copy link

melvin-bot bot commented Aug 22, 2023

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

@dukenv0307
Copy link
Contributor

dukenv0307 commented Aug 22, 2023

@cubuspl42 Should we add a empty check after we change the regex to prevent the user save rate with an empty string.?

@cubuspl42
Copy link
Contributor

@dukenv0307 I decided to postpone the heavy regex testing, including the corner cases, to the implementation phase. I definitely agree that handling corner cases is important.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 22, 2023
@GItGudRatio
Copy link
Contributor

PR is up for review, kindly review!

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Aug 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 22, 2023

📣 @Premsjce We're missing your Upwork ID to automatically send you an offer for the Reporter role.
Once you apply to the Upwork job, your Upwork ID will be stored and you will be automatically hired for future jobs!

@Premsjce
Copy link

@MelvinBot
Contributor details
Your Expensify account email: premsjce@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~0182bbbcf31ac0306f

@melvin-bot
Copy link

melvin-bot bot commented Aug 22, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@melvin-bot
Copy link

melvin-bot bot commented Aug 23, 2023

🎯 ⚡️ Woah @cubuspl42 / @GItGudRatio, great job pushing this forwards! ⚡️

The pull request got merged within 3 working days of assignment, so this job is eligible for a 50% #urgency bonus 🎉

  • when @GItGudRatio got assigned: 2023-08-22 21:36:11 Z
  • when the PR got merged: 2023-08-23 14:39:59 UTC

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Aug 28, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Reimburse - 0.5 is allowed, but .5 is not allowed [HOLD for payment 2023-09-04] [$1000] Reimburse - 0.5 is allowed, but .5 is not allowed Aug 28, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Aug 28, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 28, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 28, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.57-6 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 2023-09-04. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

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

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Aug 28, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@cubuspl42] The PR that introduced the bug has been identified. Link to the PR:
  • [@cubuspl42] 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:
  • [@cubuspl42] A discussion in #expensify-bugs 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:
  • [@cubuspl42] Determine if we should create a regression test for this bug.
  • [@cubuspl42] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@conorpendergrast / @bfitzexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@cubuspl42
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR:
    • N/A (the desired behavior was always missing in the component)
  • 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:
    • N/A
  • A discussion in #expensify-bugs 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:
    • No need for additional discussion
  • Determine if we should create a regression test for this bug.
    • No need for a new regression test
  • If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
    • N/A

@trjExpensify
Copy link
Contributor

👋 @bfitzexpensify @conorpendergrast, can you reduce the payment for @cubuspl42 by 50% when you pay this please?

We missed a regression here and I already settled up. Thanks!

@conorpendergrast
Copy link
Contributor

Sure Tom, thanks for that. Added into this comment #25514 (comment)

@Premsjce
Copy link

Premsjce commented Sep 3, 2023

@bfitzexpensify @conorpendergrast :
I’m the submitter of the issue, but didn’t get any upwork job offer yet, is this expected?
I’ve submitted proposal for the job posted as well.
Please do let me know, whats the usual process?
Thanks

@cubuspl42
Copy link
Contributor

cubuspl42 commented Sep 3, 2023

@trjExpensify @conorpendergrast Actually, technically speaking, that should be "minus $500", not "minus 50%", as this is a financial correction, not something related to this issue

@conorpendergrast
Copy link
Contributor

conorpendergrast commented Sep 4, 2023

@cubuspl42 Ah, I believe the deduction should be $1000. Here's my maths:

  • Price for the original issue was $1000, plus urgency bonus of $500. That's a total of $1500 paid you to
  • With regressions, we ignore urgency bonus and deduct 50% from the price, which makes $500 (1000 * 50%)
  • So that issue was overpaid by $1000, and that will be applied here

@conorpendergrast
Copy link
Contributor

@Premsjce offer sent now, thanks for applying on the job!

@Premsjce
Copy link

Premsjce commented Sep 4, 2023

@conorpendergrast : thank you.. accepted the offer in upwork, now the status is contract started.
When this issue is closed here only then i can submit work for payment right?

@conorpendergrast
Copy link
Contributor

I'll pay today and then close out the contract, you don't need to do anything else here!

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 Daily KSv2 labels Sep 4, 2023
@conorpendergrast
Copy link
Contributor

Payouts due:

Eligible for 50% #urgency bonus? Yes

Upwork job is here.

All done, thanks everyone. Closing out!

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
None yet
Development

No branches or pull requests