[$500] Invalid phone number is accepted when starting a new chat #32242
Description
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: 1.4.5-1
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: @MariaHCD
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1701265640069269
Action Performed:
- Start new chat
- Enter +112345678900
- Observe this invalid phone number is parsed into a valid number
Expected Result:
Invalid number should be detected
Actual Result:
The number is parsed into a valid phone number
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
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~01b8deeaa5835d9589
- Upwork Job ID: 1730299555744174080
- Last Price Increase: 2023-11-30

Activity
melvin-bot commentedon Nov 30, 2023
Triggered auto assignment to @NicMendonca (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Nov 30, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)crypto1014 commentedon Nov 30, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Invalid phone number is accepted when starting a new chat
What is the root cause of that problem?
Now, our project is using parsePhoneNumber function of
awesome-phonenumberpackage which has some bug.It sometimes accept invalid phone number as valid so we should add custom checking code after validation.
When parse number, this function convert input string to e164 type in module.
const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchInputValue)));Because of it, some invalid input string is changed to valid string.

This occurs about only invalid string.
You can know about it If you check following photo.
What changes do you think we should make in order to solve the problem?
If invalid string is entered, its input and e164 string is different, while valid string is entered, its input and e164 string is same.
so we can just add comparison code between input and e164 strings.
In OptionsListUtils.js 1132 Line
From
To
This is result.

I checked these results in native app and chrome. As a result it works well now.
What alternative solutions did you explore? (Optional)
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
[-] Invalid phone number is accepted when starting a new chat[/-][+][$500] Invalid phone number is accepted when starting a new chat[/+]melvin-bot commentedon Nov 30, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01b8deeaa5835d9589
melvin-bot commentedon Nov 30, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ntdiary (
External)kaushiktd commentedon Dec 1, 2023
Please re-state the problem that we are trying to solve in this issue.
Invalid phone number is accepted when starting a new chat
What is the root cause of that problem?
the country code 1 is removed from the number +112345678900 resulting in +12345678900, might occur due to how the country code addition and formatting are handled in the context of the awesome-phonenumber library.
What changes do you think we should make in order to solve the problem?
https://github.com/Expensify/App/blob/main/src/libs/OptionsListUtils.js#L1623
in
this will set the error if the input and e164 value is not same which solves the problem of not showing error message
also to hide the popup we need to wrap in condition,
https://github.com/Expensify/App/blob/main/src/libs/OptionsListUtils.js#L1330
Video:
https://drive.google.com/file/d/1FcEDYvB6-CxJ7WZsStJkBJ9FKr0zIFTz/view?usp=drive_link
situchan commentedon Dec 5, 2023
situchan commentedon Dec 5, 2023
akinwale commentedon Dec 5, 2023
Taking over as C+ here.
The existing proposals do not adequately address the issue. Looking for more proposals.
erichasinternet commentedon Dec 5, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
An invalid phone number is accepted when starting a new chat.
What is the root cause of that problem?
The core issue at hand stems from the functionality of the
parsePhoneNumbermethod. When the input+112345678900is processed by this method, it produces the following result:While the
number.inputvalue appears to be invalid due to the presence of an additional '1', thee164value eliminates this extraneous digit, resulting in the representation of a valid phone number.What changes do you think we should make in order to solve the problem?
We can improve the existing code by adding an extra check, comparing the e164 and input values for equality.
We'll also need to add the
e164andinputcomparison here to prevent both an account and an error message from being returned simultaneously.Bug-fix demo:
Screenshot of expected result:

Video showing expected behavior:
Screen.Recording.2023-12-05.at.1.11.20.PM.mov
melvin-bot commentedon Dec 5, 2023
📣 @erichasinternet! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Format:
erichasinternet commentedon Dec 5, 2023
Contributor details
Your Expensify account email: elawson545@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01bb13350fc87c5468
melvin-bot commentedon Dec 5, 2023
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
FitseTLT commentedon Dec 5, 2023
This will be fixed by #31726
melvin-bot commentedon Dec 5, 2023
@ntdiary, @NicMendonca Huh... This is 4 days overdue. Who can take care of this?
MariaHCD commentedon Dec 6, 2023
Seems like this one might be a dupe of #28492
Thoughts, @akinwale?
akinwale commentedon Dec 6, 2023
Yeah, looks like it. We can close this one.