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-06-28] [$250] Extra spaces are not trimmed in the next page for the routing number and Account number #43135

Open
1 of 6 tasks
m-natarajan opened this issue Jun 5, 2024 · 28 comments
Assignees
Labels
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 Jun 5, 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.79-6
Reproducible in staging?: y
Reproducible in production?: y
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
Expensify/Expensify Issue URL:
Issue reported by: @allgandalf
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1717537508312169

Action Performed:

  1. Go to a workspace
  2. Enable workflows
  3. Click on connect bank account
  4. Select manual and enter the account details as : 011401533 and account number 1111222233331111 give some space before both these numbers and press next

Expected Result:

Spaces are trimmed in the confirmation page

Actual Result:

Spaces are present on the confirmation page, we should trim them while saving as a account number cannot have spaces before or after.

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

Screen.Recording.2024-06-05.at.3.11.25.AM.mov
Recording.176.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0134151ac2072ab6de
  • Upwork Job ID: 1798588655835680495
  • Last Price Increase: 2024-06-06
  • Automatic offers:
    • allgandalf | Contributor | 102633932
    • Krishna2323 | Contributor | 102704572
Issue OwnerCurrent Issue Owner: @MitchExpensify / @Christinadobrzyn
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 5, 2024
Copy link

melvin-bot bot commented Jun 5, 2024

Triggered auto assignment to @Christinadobrzyn (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.

@allgandalf
Copy link
Contributor

@Christinadobrzyn Can i be the C+ here? as i reported this issue and have more context about the same.

@Krishna2323
Copy link
Contributor

Krishna2323 commented Jun 5, 2024

Proposal

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

Extra spaces are not trimmed in the next page for the routing number and Account number

What is the root cause of that problem?

We are not using useStepFormSubmit in Manual. useStepFormSubmit saves the trimmed value (that is passed by FormProvider onSubmit) as the new draft.

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

Use useReimbursementAccountStepFormSubmit like we do in other components and for input wrappers pass shouldSaveDraft={!isEditing}

const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: STEP_FIELDS,
onNext,
shouldSaveDraft: isEditing,
});

    const handleSubmit = useReimbursementAccountStepFormSubmit({
        fieldIds: [BANK_INFO_STEP_KEYS.ROUTING_NUMBER, BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER],
        onNext,
        shouldSaveDraft: isEditing,
    });

We will also check for other pages like this, which uses substeps.

What alternative solutions did you explore? (Optional)

@dragnoir
Copy link
Contributor

dragnoir commented Jun 5, 2024

Proposal

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

Extra spaces are not trimmed in the next page for the routing number and Account number

What is the root cause of that problem?

Values saved from Manual step with spaces and used on the next step.

<InputWrapper
InputComponent={TextInput}
ref={inputCallbackRef}
inputID={BANK_INFO_STEP_KEYS.ROUTING_NUMBER}

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

The best way to solve this issue id to make sure we don't go to the next step with wrong values (with spaces).

I suggest adding a more check on Manual step to make sure we don't accept values with spaces. This will make sure all values sent to the next steps and saved on the Onyx data are correct and safe

const validate = useCallback((values: FormOnyxValues<typeof ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM> => {

1- The values sent to the validate function are trimmed by default. You can console.log values and you will see that the space added on the form is not within those values

const validate = useCallback((values: FormOnyxValues<typeof ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM> => {

for this we need to add shouldTrimValues={false} to FormProvider so we can validate the correct values.

2- We need to add a new regex for spaces before and after
We can add a new const

REGEX: {
  US_ACCOUNT_NUMBER: /^[0-9]{4,17}$/,
  MASKED_US_ACCOUNT_NUMBER: /^[X]{0,13}[0-9]{4}$/,
  SWIFT_BIC: /^[A-Za-z0-9]{8,11}$/,
+ START_OR_END_WITH_SPACE: /^\s|\s$/,
},

3- We update the validate function to check if the values has spaces at the start or at the end

if (values.accountNumber  &&  CONST.BANK_ACCOUNT.REGEX.START_OR_END_WITH_SPACE.test(values.accountNumber)) {
  errors.accountNumber  =  'bankAccount.error.accountNumber';
}

We do the same for the routingNumber

What alternative solutions did you explore?

@Christinadobrzyn Christinadobrzyn added the External Added to denote the issue can be worked on by a contributor label Jun 6, 2024
@Christinadobrzyn
Copy link
Contributor

Christinadobrzyn commented Jun 6, 2024

@allgandalf I'm going to add the label so it's fair share but we can ask the assigned C+ if you can take it.

Copy link

melvin-bot bot commented Jun 6, 2024

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

@melvin-bot melvin-bot bot changed the title Extra spaces are not trimmed in the next page for the routing number and Account number [$250] Extra spaces are not trimmed in the next page for the routing number and Account number Jun 6, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 2024

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

@Christinadobrzyn
Copy link
Contributor

Hey @ahmedGaber93 - would you mind if @allgandalf took over as C+ since they reported this issue and have some more context?

@allgandalf
Copy link
Contributor

I'm going to add the lable so it's fair share

@Christinadobrzyn fair point, i’m okay with @ahmedGaber93 taking this over, willing to help them if they need any help on the PR phase 👍

@ahmedGaber93
Copy link
Contributor

Hey @ahmedGaber93 - would you mind if @allgandalf took over as C+ since they reported this issue and have some more context?

@Christinadobrzyn Yeah, that's fair. Please unassign me and assign @allgandalf.

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

melvin-bot bot commented Jun 7, 2024

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

@allgandalf
Copy link
Contributor

Thanks for your proposals @Krishna2323 @dragnoir

@dragnoir , In ND, at other places we silently trim the extra spaces for example. while entering phone number in personal details, we trim them, so i don't think we should block the user if they enter extra white spaces, so to stay consistent within our app, we should allow them to enter with spaces and then silently trim the value. Also the expected result of this GH is to trim those extra spaces.

@Krishna2323 , your solution would work fine for this bug, but before moving forward can you update your proposal to highlight the following points:

  • Can you be a little brief in your RCA, We are not using useStepFormSubmit in Manual. is not much clear, i can interpret what you mean but when the internal engineer reviews your proposal they might not get the exact RCA :)
  • Your solution works fine, but why do we need to create another hook useStepFormSubmit when we have useReimbursementAccountStepFormSubmit, won't it be more optimal to re-use the same hook? or am i missing something here?, like you mentioned we already use the same hook in many components.

Approach wise your proposal LGTM, but can you please address the above points once :) thanks

@Krishna2323
Copy link
Contributor

@allgandalf, proposal updated.

@allgandalf
Copy link
Contributor

@Krishna2323 ,shouldSaveDraft should always be set to true other that that your RCA is correct and solution is complete!

@Krishna2323's proposal, looks good to me, initial proposal summary can be found here

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Jun 10, 2024

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

@iwiznia
Copy link
Contributor

iwiznia commented Jun 11, 2024

useStepFormSubmit saves the trimmed value (that is passed by FormProvider onSubmit) as the new draft.

I don't see this component trimming the values, @Krishna2323 can you point out where that component would trim the value?

@Christinadobrzyn Christinadobrzyn removed their assignment Jun 12, 2024
@Christinadobrzyn Christinadobrzyn added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Jun 12, 2024
Copy link

melvin-bot bot commented Jun 12, 2024

Triggered auto assignment to @MitchExpensify (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.

@Christinadobrzyn
Copy link
Contributor

Just a heads up - I'm going to be ooo until June 24th so going to assign a teammate to watch this while I'm away.

@MitchExpensify we are discussing the proposals - #43135 (comment)

@Christinadobrzyn Christinadobrzyn self-assigned this Jun 12, 2024
@Krishna2323
Copy link
Contributor

@iwiznia, currently we pass onNext to onSubmit prop which doesn't do anything expect from moving to next page, but when we use the callback from useStepFormSubmit hook as the callback to onSubmit prop, the callback gets the form value and updates the draft values. The form value passed to onSubmit callback are already trimmed.


(values: FormOnyxValues<T>) => {
if (shouldSaveDraft) {
const stepValues = fieldIds.reduce((acc, key) => {
acc[key] = values[key];
return acc;
}, {} as Record<(typeof fieldIds)[number], OnyxValues[T][Exclude<keyof OnyxValues[T], keyof BaseForm>]>);
FormActions.setDraftValues(formId, stepValues);
}
onNext();
},

// Prepare values before submitting
const trimmedStringValues = shouldTrimValues ? ValidationUtils.prepareValues(inputValues) : inputValues;

@iwiznia
Copy link
Contributor

iwiznia commented Jun 12, 2024

Got it.

Copy link

melvin-bot bot commented Jun 12, 2024

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

@Krishna2323
Copy link
Contributor

@allgandalf, PR ready for review.

@allgandalf
Copy link
Contributor

Thanks for the PR @Krishna2323 , will review today 👍

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jun 21, 2024
@melvin-bot melvin-bot bot changed the title [$250] Extra spaces are not trimmed in the next page for the routing number and Account number [HOLD for payment 2024-06-28] [$250] Extra spaces are not trimmed in the next page for the routing number and Account number Jun 21, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jun 21, 2024
Copy link

melvin-bot bot commented Jun 21, 2024

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

Copy link

melvin-bot bot commented Jun 21, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.85-7 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-06-28. 🎊

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

Copy link

melvin-bot bot commented Jun 21, 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:

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

@MitchExpensify
Copy link
Contributor

MitchExpensify commented Jun 24, 2024

Payment summary:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 27, 2024
@Christinadobrzyn
Copy link
Contributor

There are no regressions, so I'm paying this out based on this payment summary - #43135 (comment)

@allgandalf can you let us know about a regression test?

@Christinadobrzyn Christinadobrzyn removed the Awaiting Payment Auto-added when associated PR is deployed to production label Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Status: No status
Development

No branches or pull requests

8 participants