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-04-09] [$500] On Validate your bank account page, no invalid amount error if the lasts digits are "0" #37974

Closed
2 of 6 tasks
m-natarajan opened this issue Mar 8, 2024 · 55 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

@m-natarajan
Copy link

m-natarajan commented Mar 8, 2024

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


Version Number: 1.4.49-0
Reproducible in staging?: y
Reproducible in production?: 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):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: applause internal team
Slack conversation:

Action Performed:

Pre-requisite: user must be logged in and have created a workspace.

  1. Go to Workspace > Bank account.
  2. Select "Connect manually".
  3. Go trough the add BA flow with the testing credentials until you reach the "Validate your bank account page".
  4. On a transaction field, enter any 8 digits.
  5. Verify no error is displayed.
  6. Verify that if you enter any other digit than "0", an error for invalid amount is displayed.
  7. Clear the field.
  8. Enter any 8 digits.
  9. After the 8 digits, enter "0" many times.
  10. Verify no error is displayed.

Expected Result:

The invalid amount error should be displayed if the number entered has more than 8 digits.

Actual Result:

The invalid amount error is not displayed if the last digits are "0".

Workaround:

unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6406504_1709873247666.Fjxr0832_1_.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~015f8c244843935a8f
  • Upwork Job ID: 1770500300003213312
  • Last Price Increase: 2024-03-20
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 8, 2024
Copy link

melvin-bot bot commented Mar 8, 2024

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

@m-natarajan
Copy link
Author

@alexpensify 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.

@bernhardoj
Copy link
Contributor

Proposal

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

User can input the test transaction amount with more than 8 digit if the leading and trailing amount is 0s.

What is the root cause of that problem?

The input is validated using the regex as shown below where the max digit is 8 (and 2 digit for decimal).

const amountRegex = RegExp(String.raw`^-?\d{0,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{0,${CurrencyUtils.getCurrencyDecimals(outputCurrency)}})?$`, 'i');
Object.keys(amountValues).forEach((key) => {
const value = amountValues[key as keyof AmountValues];
const filteredValue = filterInput(value, amountRegex);
if (ValidationUtils.isRequiredFulfilled(filteredValue.toString())) {
return;
}
errors[key as keyof AmountValues] = 'common.error.invalidAmount';

It's validating using filterInput function where it will returns an empty string if it's not a valid input.

const filterInput = (amount: string, amountRegex?: RegExp) => {
let value = amount ? amount.toString().trim() : '';
value = value.replace(/^0+|0+$/g, '');
if (value === '' || Number.isNaN(Number(value)) || !Math.abs(Str.fromUSDToNumber(value, false)) || (amountRegex && !amountRegex.test(value))) {
return '';
}
return value;

The problem here is that we test the regex with value variable which omits all leading and trailing 0s from the user input.

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

We should test the regex with the untouched user input, that is amount.

amountRegex && !amountRegex.test(amount)

@allgandalf
Copy link
Contributor

allgandalf commented Mar 8, 2024

Proposal

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

On Validate your bank account page, no invalid amount error if the lasts digits are "0"

What is the root cause of that problem?

We have current regex which doesn't account for the trailing zeros if there is no decimal value

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

We need to update the amountRegex to consider the cases where there are tailing zeros but no decimal places, this can be done with the following update:

const amountRegex = RegExp(String.raw`^-?(0|[1-9]\d{0,7})([${getPermittedDecimalSeparator(decimalSeparator)}]\d*?[1-9](0{0,${CurrencyUtils.getCurrencyDecimals(outputCurrency)}})?)?$`, 'i');

Also updated filterInput function would be:

const filterInput = (amount: string, amountRegex?: RegExp) => {
    let value = amount ? amount.toString().trim() : '';
    // Remove leading zeros except when the value is '0'
    value = value.replace(/^0+(?!=\.|$)/, '');
    if (value === '' || Number.isNaN(Number(value)) || !Math.abs(Str.fromUSDToNumber(value, false)) || (amountRegex && !amountRegex.test(value))) {
        return '';
    }

    return value;
};

Result Video:

simplescreenrecorder-2024-03-22_19.49.44.mp4

@melvin-bot melvin-bot bot added the Overdue label Mar 11, 2024
@dragnoir
Copy link
Contributor

@m-natarajan can you pls explain from where did you got the Expected Result: you mentioned!!

The invalid amount error should be displayed if the number entered has more than 8 digits.?

Copy link

melvin-bot bot commented Mar 11, 2024

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

@alexpensify
Copy link
Contributor

No update yet, I need to test.

@melvin-bot melvin-bot bot removed the Overdue label Mar 11, 2024
@alexpensify
Copy link
Contributor

I'll test this one tomorrow.

@melvin-bot melvin-bot bot added the Overdue label Mar 15, 2024
@alexpensify
Copy link
Contributor

No update

@alexpensify
Copy link
Contributor

Still on my testing list.

@melvin-bot melvin-bot bot removed the Overdue label Mar 18, 2024
@allgandalf
Copy link
Contributor

bump @alexpensify

@alexpensify
Copy link
Contributor

Perfect timing since I was testing this one right now. Ok, so I confirmed that if you input a all zeros, there will be an error. The issue is isolated to when you input numbers then have trailing zeros.

Error

2024-03-20_10-13-16

2024-03-20_10-15-34

No Error

2024-03-20_10-14-48

2024-03-20_10-13-57


I believe we should fix this one. If you input a valid number and a trailing zero, the process will try to save the account.

@alexpensify alexpensify added the External Added to denote the issue can be worked on by a contributor label Mar 20, 2024
@melvin-bot melvin-bot bot changed the title On Validate your bank account page, no invalid amount error if the lasts digits are "0" [$500] On Validate your bank account page, no invalid amount error if the lasts digits are "0" Mar 20, 2024
Copy link

melvin-bot bot commented Mar 20, 2024

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

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

melvin-bot bot commented Mar 20, 2024

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

@alexpensify
Copy link
Contributor

@hungvu193 - can you please review the proposals to identify if one fixes this issue? Thanks!

@allgandalf
Copy link
Contributor

@alexpensify , you tested this on the bank account page, does this work same as the amount validation page?

@hungvu193
Copy link
Contributor

What do you think about my proposal @hungvu193 , won’t it be better to modify the regex instead?

I think that's fine. However you can check the testcases on your proposal, it failed on these cases where we have trailing zeros or only dot without any number.

@tienifr
Copy link
Contributor

tienifr commented Mar 25, 2024

What do you think about my #37974 (comment) @hungvu193 , won’t it be better to modify the regex instead?

@GandalfGwaihir RegEx is expensive. This RegEx you're trying to modify is already a complex one, we shouldn't add more to it, especially when there's much simpler solution that works for all cases and has no disadvantage

@allgandalf
Copy link
Contributor

Thanks for the feedback @hungvu193 @tienifr , will try to improve proposal next time 😄

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

melvin-bot bot commented Mar 25, 2024

❌ There was an error making the offer to @hungvu193 for the Reviewer role. The BZ member will need to manually hire the contributor.

Copy link

melvin-bot bot commented Mar 25, 2024

❌ There was an error making the offer to @tienifr for the Contributor role. The BZ member will need to manually hire the contributor.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Mar 27, 2024
@tienifr
Copy link
Contributor

tienifr commented Mar 27, 2024

@hungvu193 PR #39039 is ready to review

@alexpensify
Copy link
Contributor

Cool, now we wait for automation here.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Apr 2, 2024
@melvin-bot melvin-bot bot changed the title [$500] On Validate your bank account page, no invalid amount error if the lasts digits are "0" [HOLD for payment 2024-04-09] [$500] On Validate your bank account page, no invalid amount error if the lasts digits are "0" Apr 2, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Apr 2, 2024
Copy link

melvin-bot bot commented Apr 2, 2024

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

Copy link

melvin-bot bot commented Apr 2, 2024

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

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

  • @hungvu193 requires payment (Needs manual offer from BZ)
  • @tienifr requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented Apr 2, 2024

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:

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

@alexpensify
Copy link
Contributor

@tienifr and @hungvu193 - to prepare for the payment process, please accept the invitation for the following Upwork job:

https://www.upwork.com/jobs/~015f8c244843935a8f

Thanks! I'll complete the process tomorrow.

@hungvu193
Copy link
Contributor

@tienifr and @hungvu193 - to prepare for the payment process, please accept the invitation for the following Upwork job:

https://www.upwork.com/jobs/~015f8c244843935a8f

Thanks! I'll complete the process tomorrow.

I've just accepted. Thank you.

@tienifr
Copy link
Contributor

tienifr commented Apr 8, 2024

@alexpensify I've accepted as well, thanks!

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Apr 8, 2024
@alexpensify
Copy link
Contributor

alexpensify commented Apr 9, 2024

Thanks! Everyone has been paid in Upwork.

Payouts due: 2024-04-09

Upwork job is here.

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
No open projects
Archived in project
Development

No branches or pull requests

8 participants