-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[$125] Web - Expensify Card - Inconsistent behavior of phone number validation for shipping details #51491
Comments
Triggered auto assignment to @garrettmknight ( |
We think that this bug might be related to #wave-collect - Release 2 |
@garrettmknight 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 |
ProposalPlease re-state the problem that we are trying to solve in this issue.Web - Expensify Card - Inconsistent behavior of phone number validation for shipping details What is the root cause of that problem?When we fill the phone number inside the shipping details, we check if the user adds country code then we'll return the current phone number else we will add from the IP App/src/pages/MissingPersonalDetails/substeps/PhoneNumber.tsx Lines 38 to 42 in 9508b17
But inside the wallet page we only check if the user have not yet add the country code, we will return an error App/src/pages/settings/Wallet/Card/GetPhysicalCardPhone.tsx Lines 44 to 45 in 9508b17
What changes do you think we should make in order to solve the problem?We can do the same way like we do inside shipping details, we will check if the user has not yet add the country code then we will the country code form the IP else return the current phone number const onValidate = (values: OnyxEntry<GetPhysicalCardForm>): OnValidateResult => {
const {phoneNumber: phoneNumberToValidate = ''} = values ?? {};
const errors: OnValidateResult = {};
if (!ValidationUtils.isRequiredFulfilled(phoneNumberToValidate)) {
errors.phoneNumber = translate('common.error.fieldRequired');
}
const phoneNumberWithCountryCode = LoginUtils.appendCountryCode(phoneNumberToValidate);
const parsedPhoneNumber = PhoneNumberUtils.parsePhoneNumber(phoneNumberWithCountryCode);
if (!parsedPhoneNumber.possible || !Str.isValidE164Phone(phoneNumberWithCountryCode.slice(0))) {
errors.phoneNumber = translate('bankAccount.error.phoneNumber');
}
return errors;
}; And we also need to fix the App/src/libs/GetPhysicalCardUtils.ts Lines 18 to 20 in 9508b17
to: const phoneNumberWithCountryCode = LoginUtils.appendCountryCode(phoneNumber ?? '');
const parsedPhoneNumber = PhoneNumberUtils.parsePhoneNumber(phoneNumberWithCountryCode);
if (!phoneNumber || !parsedPhoneNumber.possible || !Str.isValidE164Phone(phoneNumberWithCountryCode.slice(0))) {
return ROUTES.SETTINGS_WALLET_CARD_GET_PHYSICAL_PHONE.getRoute(domain);
} What alternative solutions did you explore? (Optional) |
Job added to Upwork: https://www.upwork.com/jobs/~021850956027322769046 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @sobitneupane ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.Inconsistent behavior of phone number validation for shipping details What is the root cause of that problem?We have different validation function on the get physical cards page: App/src/pages/settings/Wallet/Card/GetPhysicalCardPhone.tsx Lines 39 to 45 in 9508b17
This doesn't match with the existing logic to verify on shipping page and hence we have this bug. What changes do you think we should make in order to solve the problem?I found one more page where we use phone number validation: App/src/pages/settings/Profile/PersonalDetails/PhoneNumberPage.tsx Lines 49 to 53 in 444633c
In settings profile page. This inconsistency is going to increase over time and will be difficult to maintain overtime as we will be needing to change logic as we need in future. So to not cause inconsistency again and to be more streamlined, I propose that we create a common util function common to all the pages where we verify mobile number for shipping and then validate against that util.: function validatePhoneNumber(phoneNumber: string): string {
// Check if the phone number field is empty
if (!ValidationUtils.isRequiredFulfilled(phoneNumber)) {
return translate('common.error.fieldRequired');
}
// Append country code if necessary
const formattedPhoneNumber = LoginUtils.appendCountryCode(phoneNumber);
// Parse and validate the phone number
const parsedPhoneNumber = PhoneNumberUtils.parsePhoneNumber(formattedPhoneNumber);
if (!parsedPhoneNumber.possible || !Str.isValidE164Phone(formattedPhoneNumber)) {
return translate('bankAccount.error.phoneNumber');
}
// Return an empty string to indicate no error
return '';
} and then we can use it consistently in all of our pages: const validate = useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.PERSONAL_DETAILS_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.PERSONAL_DETAILS_FORM> => {
const errors: FormInputErrors<typeof ONYXKEYS.FORMS.PERSONAL_DETAILS_FORM> = {};
const phoneError = validatePhoneNumber(values[INPUT_IDS.PHONE_NUMBER]);
if (phoneError) {
errors[INPUT_IDS.PHONE_NUMBER] = phoneError;
}
return errors;
},
[translate],
); This way we are consistent with the shipping number validation flow What alternative solutions did you explore? (Optional) |
Thanks for the proposal, @NJ-2020 and @twilight2294 Were you able to reproduce the issue? There are several components in the app that use phone numbers, so I think it would be good to review all of them to ensure consistent behavior. |
@sobitneupane Yes i was able to reproduce the issue After checking again, i can confirm that the issue only occurring on wallet get physical card page only |
Yes i checked, actually there is one place where we use different validation, and that is for the login/signup page, there we shouldn't club the logic as there we allow, non-US numbers, we are good here |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
Triggered auto assignment to @chiragsalian, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
Proposal LGTM, feel free to create the PR @NJ-2020 |
PR ready cc: @sobitneupane |
This issue has not been updated in over 15 days. @garrettmknight, @chiragsalian, @sobitneupane, @NJ-2020 eroding to Monthly issue. P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do! |
Waiting on @NJ-2020 to make a few changes in the PR. |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
We are reverting this PR |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.78-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 2025-01-02. 🎊 For reference, here are some details about the assignees on this issue:
|
@sobitneupane @garrettmknight @sobitneupane 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] |
@sobitneupane Let's discuss the regression issue here since the issue here has been closed Btw for this issue you mentioned here is a known issue(similar) and also I think this issue is coming not from my PR because this issue is created after my PR was reverted And also I think we can go for this PR+(reimplement the reverted changes), wdyt? Thanks |
Upwork job price has been updated to $125 |
Friendly bump @sobitneupane |
@sobitneupane Based on my comment here #54487 (comment), I couldn't reproduce the issue, But I can see that we're not passing the IP country code(if the user does not provide) inside onSubmit function here |
@NJ-2020 do you think this could be causing the issue? Could you please provide more details on why you believe it might be responsible for the problem? |
@sobitneupane Okay, I will try to reproduce the issue again and find the root cause |
@sobitneupane I couldn't reproduce the issue, I've tried using 2 accounts without filling the personal details info The first account is verified by still I couldn't reproduce the issue (using staging server): Screen.Recording.2025-01-08.at.17.32.42.2.movThe second account is not verified but I got another error which is Card data is missing in response(using staging server) Screen.Recording.2025-01-08.at.17.47.06.1.movAnd also even I reverted my changes the error still happening |
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.53-0
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): nathanmulugetatesting+1943@gmail.com
Issue reported by: Applause Internal Team
Action Performed:
Pre-conditions:
Expected Result:
The phone number validation works the same on both pages
Actual Result:
The phone number validation works inconsistently, when going through the form from the workspace chat page prepending "1" only works fine but when going through the form from the wallet page user has to additionally prepend "+" before "1" in order for the phone number to be accepted.
Workaround:
Unknown
Platforms:
Screenshots/Videos
Bug6643815_1729722869946.bandicam_2024-10-24_01-24-08-489.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @sobitneupaneThe text was updated successfully, but these errors were encountered: