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-10-13] [$500] Chat - App does not allow pasting number if numbers has comma in end for english and vice versa #28548

Closed
6 tasks done
lanitochka17 opened this issue Sep 30, 2023 · 35 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 Sep 30, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Open the app
  2. Open any report
  3. If language is English, write any number and write full stop in the end and copy it eg: '2000.'
  4. Paste text in plus->request money and observe that it allows to paste the text
  5. Similarly try copy number with comma in middle and observe that app allows to paste
  6. Similarly, try copy number with comma in end and observe that now app does not allow to paste the number
  7. If language is Spanish, follow all the above steps just use full stop in place of comma

Expected Result:

App should allow copy pasting number in request money with comma in end as it allows copy paste of number with comma in middle or copy paste of number with full stop in end (English language)

Actual Result:

App does not allow copy pasting number in request money with comma in end for English language and it doesn't allow copy paste number with full stop in end for Spanish language

Workaround:

Unknown

Platforms:

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

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

Version Number: 1.3.74-2

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:

windows.chrome.comma.or.fullstop.in.english.or.spanish.in.end.does.not.paste.amount.mp4
Recording.115.mp4
android.native.does.not.allow.to.paste.numbers.with.comma.1.mp4
Ipste.mp4
Ipse2.mp4

Expensify/Expensify Issue URL:

Issue reported by: @dhanashree-sawant

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~017fcdbf8f05309fae
  • Upwork Job ID: 1708219578554970112
  • Last Price Increase: 2023-09-30
  • Automatic offers:
    • Ollyws | Reviewer | 26999991
    • c3024 | Contributor | 26999997
    • dhanashree-sawant | Reporter | 26999998
@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 Sep 30, 2023
@c3024
Copy link
Contributor

c3024 commented Sep 30, 2023

Proposal

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

Pasting amount like 20, is not shown in the new request amount page.

What is the root cause of that problem?

We are using this regex here

function validateAmount(amount: string): boolean {
const decimalNumberRegex = new RegExp(/^\d+(,\d+)*(\.\d{0,2})?$/, 'i');
return amount === '' || (decimalNumberRegex.test(amount) && calculateAmountLength(amount) <= CONST.IOU.AMOUNT_MAX_LENGTH);
}

to validate the amount and this regex requires at least a digit to be followed by comma to be valid.
If the amount is not valid it just sets the previous amount.

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

I think since we are allowing 20. as valid it is reasonable to allow 20, also as valid.
Regex for this would be

const decimalNumberRegex = new RegExp(/^\d+(,\d*)?(\.\d{0,2})?$/, 'i');

This accepts 20, but disallows 20,,, this is in line with the present regex allowing 20. but not 20...
We can change the regex if we need a different vaidation

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot changed the title Chat - App does not allow pasting number if numbers has comma in end for english and vice versa [$500] Chat - App does not allow pasting number if numbers has comma in end for english and vice versa Sep 30, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 30, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 30, 2023

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

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

melvin-bot bot commented Sep 30, 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 Sep 30, 2023

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

@Krishna2323
Copy link
Contributor

Proposal

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

App does not allow pasting number if numbers has comma in end for english and vice versa.

What is the root cause of that problem?

The root cause of the problem lies in the regular expression used for validation. The current regex pattern doesn't account for numbers that end with a comma.

const decimalNumberRegex = new RegExp(/^\d+(,\d+)*(\.\d{0,2})?$/, 'i');

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

To address this issue, we should update the regular expression used for number validation to accommodate numbers with a trailing comma.

const decimalNumberRegex = new RegExp(/^\d+(,\d+)*(\.\d{0,2})?,?$/, 'i');

Result

@Ollyws
Copy link
Contributor

Ollyws commented Oct 1, 2023

@c3024 @Krishna2323 Thanks for the proposals, modifying this regex works but can either of you tell me why pasting a trailing comma works for when the language is set to English but not to Spanish?

@c3024
Copy link
Contributor

c3024 commented Oct 1, 2023

, and . are interchanged in Spanish. So we can paste 20, in Spanish but not 20. @Ollyws

@c3024
Copy link
Contributor

c3024 commented Oct 1, 2023

With the existing regex 20, works for Spanish but not English. 20. works for English but not for Spanish.
With the modified regex 20, and 20. work for both Spanish and English.

why pasting a trailing comma works for when the language is set to English but not to Spanish?

Which regex does this? As far as I see, existing regex allows 20, for Spanish but not for English. New regex allows 20, for both.
I don't see a case where 20, works for English but not Spanish like you mentioned. @Ollyws

@Ollyws
Copy link
Contributor

Ollyws commented Oct 1, 2023

@c3024 Thanks for the explanation. Sorry I meant Spanish but not to English?.
I think we need to define which punctuation is acceptable to have at the end here.
Because @c3024, your regex will allow 1,.
and @Krishna2323 your regex will allow 1.,
Not that it's a huge issue, just seems a little inconsistent to allow ,. and not .,, preferably just either , or . would be better.

@c3024
Copy link
Contributor

c3024 commented Oct 1, 2023

Once it passes the validity check ',' ('.') are stripped in English (Spanish) here

const strippedAmount = MoneyRequestUtils.stripCommaFromAmount(newAmountWithoutSpaces);

So I think allowing (or disallowing) 1,. (or for that matter 1.,) is a non-issue. Restricting (or allowing) regex for these cases is not necessary in my opinion.

But if we want to restrict our regex to allow only , and . we can use this regex

const decimalNumberRegex = new RegExp(/^(\d+(,\d+)*)+(\.\d{0,2})?$|^\d+\.$|^(\d+,)+$/, 'i');

With this regex

Screen.Recording.2023-10-01.at.11.06.49.PM.mov

@Ollyws

@Ollyws
Copy link
Contributor

Ollyws commented Oct 3, 2023

I agree, it's not really an issue worth complicating the regex for.
@c3024's proposal looks good to me.
🎀👀🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Oct 3, 2023

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

@Krishna2323
Copy link
Contributor

@Ollyws, sorry for the delay, have you tested @c3024's proposal? I'm unable to paste number with multiple commas.
Pls try with "20,0,0,0," or "10,0,0"

@Ollyws
Copy link
Contributor

Ollyws commented Oct 3, 2023

Yeah they changed the * quantifier for a ? but I assumed that was a typo.
const decimalNumberRegex = new RegExp(/^\d+(,\d*)*(\.\d{0,2})?$/, 'i'); is what I was testing with.

@Krishna2323
Copy link
Contributor

@Ollyws, that's the reason I commented a proposal here, the provided proposal was not working correctly.

@Ollyws
Copy link
Contributor

Ollyws commented Oct 3, 2023

Thanks for you proposal but @c3024 posted the general solution first, and it includes the correct solution (albeit with one extraneous character) so I think it's fair to go with their proposal.

@Krishna2323
Copy link
Contributor

Krishna2323 commented Oct 3, 2023

@Ollyws okay, thanks for clarification, I was just trying to point out that the original proposal will not work.

@Krishna2323
Copy link
Contributor

@Ollyws, sorry for disturbance again but this regex also has an issue, I can paste numbers like "1,,,,,,00,,,,,"

@Ollyws
Copy link
Contributor

Ollyws commented Oct 3, 2023

Yes I noticed this, I don't think it's necessarily unwanted behaviour as we strip all the commas anyway.

@Krishna2323
Copy link
Contributor

@Ollyws, currently we disallow number with multiple commas, in our staging version we can't paste "10,,,0"

@Ollyws
Copy link
Contributor

Ollyws commented Oct 3, 2023

Yes I am aware of this.

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

melvin-bot bot commented Oct 3, 2023

📣 @Ollyws 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot
Copy link

melvin-bot bot commented Oct 3, 2023

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

@luacmartins
Copy link
Contributor

Thanks for reviewing the proposals @Ollyws!

@melvin-bot
Copy link

melvin-bot bot commented Oct 3, 2023

📣 @dhanashree-sawant 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@c3024 c3024 mentioned this issue Oct 3, 2023
59 tasks
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Oct 3, 2023
@c3024
Copy link
Contributor

c3024 commented Oct 3, 2023

PR #28736 ready for review @Ollyws

@melvin-bot
Copy link

melvin-bot bot commented Oct 4, 2023

🎯 ⚡️ Woah @Ollyws / @c3024, 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 @c3024 got assigned: 2023-10-03 14:55:37 Z
  • when the PR got merged: 2023-10-04 16:07:27 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 Oct 6, 2023
@melvin-bot melvin-bot bot changed the title [$500] Chat - App does not allow pasting number if numbers has comma in end for english and vice versa [HOLD for payment 2023-10-13] [$500] Chat - App does not allow pasting number if numbers has comma in end for english and vice versa Oct 6, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 6, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 6, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 6, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.78-4 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-10-13. 🎊

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 Oct 6, 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:

  • [@Ollyws] The PR that introduced the bug has been identified. Link to the PR:
  • [@Ollyws] 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:
  • [@Ollyws] 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:
  • [@Ollyws] Determine if we should create a regression test for this bug.
  • [@Ollyws] 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.
  • [@sonialiap] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Oct 12, 2023
@Ollyws
Copy link
Contributor

Ollyws commented Oct 13, 2023

BugZero Checklist:
I don't think we can really say this is a regression from any PR, it was just something not previously considered to add to the regex.
I don't think a regression test is necessary here as it is a very edge-case issue and doesn't affect the flow in any significant way.

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

melvin-bot bot commented Oct 16, 2023

@Ollyws, @sonialiap, @luacmartins, @c3024 Whoops! This issue is 2 days overdue. Let's get this updated quick!

@luacmartins
Copy link
Contributor

luacmartins commented Oct 16, 2023

Agreed with @Ollyws's assessment. I believe we're just pending payment.

@melvin-bot melvin-bot bot removed the Overdue label Oct 16, 2023
@sonialiap
Copy link
Contributor

@Ollyws review + bonus = $750 - paid ✔️
@c3024 fix + bonus = $750 - paid ✔️
@dhanashree-sawant report = $50 - paid ✔️

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

6 participants