-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[PhoneNumber Verification] Display only valid numbers in user search. #17578
[PhoneNumber Verification] Display only valid numbers in user search. #17578
Conversation
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
@stitesExpensify @s77rt One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
As raised in this comment here, we should replace all instances of There are all the occurrences of the
|
I would think that we do want to replace all uses of |
@puneetlath for instance: In the
here, if the input is |
This is the regex for the I believe that the function name isValidPhone refers to the format of the number and not if the number itself is a valid number or not. Maybe we can replace it with |
|
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
@Prince-Mendiratta We can't keep using Str.isValidPhone because it creates inconsistency, if we validate input as a valid number at stage 1 (that uses Str.isValidPhone) then say the number is not correct at stage 2 (using the lib) we will create a confusion. |
@s77rt I can notice a slight glitch when the last digit for a valid number is added. The header message changes to No results found before the new result shows up. Is this okay? 2023-04-19.00-12-03.mp4 |
@Prince-Mendiratta I noticed the same bug previously, it should be fixed with the suggested change here #17255 (comment) Or this didn't do it? |
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
@s77rt updated, please have a look!
Nope, it's still pretty noticeable. I think this might be because the header message is updated before we can show the user |
@Prince-Mendiratta I'm still unable to reproduce the bug, can you please double check? |
@s77rt Here's the video and reproduction steps:
Realtime 2023-04-19.01-45-29.mp4Slowed to 0.5x 2023-04-19-01-45-29_q3UUtRsb.mp4 |
Still can't reproduce, can you add a |
@Prince-Mendiratta I really can't reproduce that. Sorry if I'm being repetitive but are you sure you are applying the changes exactly as they are in the PR? git checkout then git apply https://github.com/Expensify/App/pull/17578.diff |
Ah okay, I was trying on the New Chat page. I confirm the bug is reproducible on the Search page. Let's fix that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! You have some merge conflicts though.
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
e818808
Conflicts resolved, should be good to merge @puneetlath! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, loving the clean up! Just a couple of questions
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
@Prince-Mendiratta sorry, but you've got some conflicts now. @stitesExpensify let us know if you're good and we can get this merged today! |
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Hey @Prince-Mendiratta Sorry to bother you but the last commit of resolving conflicts undid the fix for the highlighted bug here #17578 (comment) |
Ah, woops. I was focused on resolving conflicts and forgot to recheck the commit. I've got the changes ready, let me know when I can put up a follow up PR. |
Let's revert since we still have the ability. And we can add the fix to an updated PR. @Prince-Mendiratta please go ahead and open a separate PR with these changes and the fix. |
@puneetlath @s77rt Just to confirm, after adding the new changes, I'll have to revert the revert in order to add all the changes, right? I'm not able to see all the changes in any other case. The final commit graph would look like: |
That works |
PR is up for review! |
🚀 Deployed to staging by https://github.com/stitesExpensify in version: 1.3.8-0 🚀
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.3.8-8 🚀
|
This PR caused a regression in #20233, more context #20233 (comment) , When we have |
@fedirjh Hmm is this the offending PR? I don't think we changed that behaviour, previously we weren't taking the sms domain in consideration either. const isPhoneNumber = CONST.REGEX.PHONE_WITH_SPECIAL_CHARS.test(searchInputValue);
const searchValue = isPhoneNumber ? searchInputValue.replace(CONST.REGEX.NON_NUMERIC_WITH_PLUS, '') : searchInputValue; |
@@ -676,25 +671,21 @@ function getOptions(reports, personalDetails, { | |||
const noOptions = (recentReportOptions.length + personalDetailsOptions.length) === 0; | |||
const noOptionsMatchExactly = !_.find(personalDetailsOptions.concat(recentReportOptions), option => option.login === searchValue.toLowerCase()); | |||
|
|||
// If the phone number doesn't have an international code then let's prefix it with the | |||
// current user's international code based on their IP address. | |||
const login = LoginUtils.appendCountryCode(searchValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm is this the offending PR?
@s77rt Reverting this PR fixes the issue. I believe this line is the root cause, with old code we were appending the country code after we validate the phone number. So if the country code is +1
and we search for valid number with @expensify.sms
, for example 5005550006@expensify.sms
the old code will return +15005550006@expensify.sms
, however with this PR , specifically this line
const searchValue = parsedPhoneNumber.possible ? parsedPhoneNumber.number.e164 : searchInputValue;
parsedPhoneNumber
will fail for @expensify.sms
and will fallback to the searchInputValue
which is 5005550006@expensify.sms
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah so the bug is searching for 5005550006@expensify.sms
won't work? I think you are right this is the offending PR. We didn't really check for this case at all 5005550006@expensify.sms
does not seem like a valid login.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah so the bug is searching for 5005550006@expensify.sms won't work?
The bug is that when you are logged in using a phone number +15005550006
, when inviting a new user to your workspace , without appending the country code , the code will fail to exclude your login and given that 5005550006@expensify.sms
is a valid email format, it will give you the possibility to invite that user , later when the backend verify that it will return an error . We fixed that by :
- Always removing phone number domain
@expensify.sms
before validating a phone. - Excluding any email with
@expensify.sms
domain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fedirjh Yeah I got it, previously we used to append the country code to every input, but now we only do it for valid numbers. +5005550006@expensify.sms
is not considered as a valid number so we end up using 5005550006@expensify.sms
. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting case. I would also think that we don't need to support @expensify.sms
in search, but I guess there's no downside that we do now. Thanks!
Details
With this PR, we are adding the ability to only show valid phone number users in the search page when a user enters a number.
Fixed Issues
$ #17461
PROPOSAL: #17461 (comment)
Tests
Verify the test steps above for these pages:
Search Page
New group page
New chat page
Send Money
Request Money
Split Bill
Workspace - Invite Members
Verify that no errors appear in the JS console
Offline tests
Ensure that phone number validation works even when offline.
QA Steps
Same as above.
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
web.mp4
Mobile Web - Chrome
android-mWeb.mp4
Mobile Web - Safari
iOS-mWeb.mp4
Desktop
desktop.mp4
iOS
iOS.mp4
Android
android.mp4