-
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
[HOLD] Excluded Concierge, Chronos and receipts from IOU Requests search #4504
[HOLD] Excluded Concierge, Chronos and receipts from IOU Requests search #4504
Conversation
@marcaaron I see a conflict in this PR due to some recent changes so will move it to draft and mark it ready after resolving conflicts. |
I Have tested it once again & all checks are passed marking it ready for review. |
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. Just left a few comments.
src/libs/OptionsListUtils.js
Outdated
@@ -307,6 +307,25 @@ function isCurrentUser(userDetails) { | |||
return result; | |||
} | |||
|
|||
/** | |||
* Returns whether the given userDetails is excluded from IOU request | |||
* @param {Objecy} userDetails |
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.
typo Object
src/libs/OptionsListUtils.js
Outdated
/** | ||
* Returns whether the given userDetails is excluded from IOU request | ||
* @param {Objecy} userDetails | ||
* @returns {Bool} |
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.
Boolean
src/libs/OptionsListUtils.js
Outdated
|
||
if (userDetails && userDetails.login) { | ||
const login = userDetails.login.toLowerCase(); | ||
return login === CONST.EMAIL.CHRONOS || login === CONST.EMAIL.CONCIERGE || login === CONST.EMAIL.RECEIPTS; |
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.
Something like this is a bit more readable to me. And we could also make the array a constant like EXPENSIFY_EMAILS
.
_.contains([CONST.EMAIL.CHRONOS, CONST.EMAIL.CONCIERGE, CONST.EMAIL.RECEIPTS], 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.
For adding EXPENSIFY_EMAILS
in CONST
,
with underscore (we need to import underscore)
get EXPENSIFY_EMAILS() {
return _.map(_.allKeys(this.EMAIL), key => this.EMAIL[key]);
},
Without _ underscore library
get EXPENSIFY_EMAILS() {
return Object.keys(this.EMAIL).map(key => this.EMAIL[key]);
},
which way do you prefer @marcaaron ?
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.
_.keys()
is what we use instead of Object.keys()
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.
but _.map()
also works on object values
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.
I'm not sure I'd do what you are suggesting though because if someone adds a new CONST.EMAIL.SOMETHING
it will automatically get excluded from the IOUs (which might not be intended). Better to be specific I think.
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.
So with the underscore library then, I'll update a PR Soon!
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.
Yeah, but I'm also saying we can skip underscore entirely and just do something explicit like this
get EXPENSIFY_EMAILS() {
return [
this.EMAIL.CHRONOS,
this.EMAIL.CONCIERGE,
this.EMAIL.RECEIPTS,
];
}
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.
I'm not sure I'd do what you are suggesting though because if someone adds a new CONST.EMAIL.SOMETHING will automatically get excluded from the IOUs (which might not be intended). Better to be specific I think.
Yes, it might be unintended, so like you said we can keep it specific. Then this should work.
get EXPENSIFY_EMAILS() {
return [
this.EMAIL.CHRONOS,
this.EMAIL.CONCIERGE,
this.EMAIL.RECEIPTS,
];
},
Working on the request changes |
@marcaaron Requested changes have been updated. |
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.
This is testing well for me. Just leaving a thought here on how to improve this. I feel the isExcludedIOUUsers
method we are exporting is unlikely to be used in many places and should be part of the internal logic of getOptions()
@@ -94,7 +94,7 @@ class IOUParticipantsRequest extends Component { | |||
indexOffset: 0, | |||
}); | |||
|
|||
if (this.state.userToInvite && !isCurrentUser(this.state.userToInvite)) { | |||
if (this.state.userToInvite && !isExcludedIOUUsers(this.state.userToInvite)) { |
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.
This looked good to me initially, but I am now second guessing it. It feels like it would be more appropriate to just not return a userToInvite
from getOptions()
.
Then we would not need to import this method into these two places and would probably not need the method at all. Just don't allow setting userToInvite
if they are one of the emails:
App/src/libs/OptionsListUtils.js
Lines 505 to 525 in 95bf36d
let userToInvite = null; | |
if (searchValue | |
&& recentReportOptions.length === 0 | |
&& personalDetailsOptions.length === 0 | |
&& !isCurrentUser({login: searchValue}) | |
&& _.every(selectedOptions, option => option.login !== searchValue) | |
&& ((Str.isValidEmail(searchValue) && !Str.isDomainEmail(searchValue)) || Str.isValidPhone(searchValue)) | |
&& (!_.find(loginOptionsToExclude, loginOptionToExclude => loginOptionToExclude.login === searchValue)) | |
&& (searchValue !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas)) | |
) { | |
// 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 = (Str.isValidPhone(searchValue) && !searchValue.includes('+')) | |
? `+${countryCodeByIP}${searchValue}` | |
: searchValue; | |
const userInvitePersonalDetails = getPersonalDetailsForLogins([login], personalDetails); | |
userToInvite = createOption(userInvitePersonalDetails, null, draftComments, { | |
showChatPreviewLine, | |
}); | |
userToInvite.icons = [defaultAvatarForUserToInvite]; | |
} |
We'd still need to do some kind of boolean flag like shouldInviteExpensifyEmails
passed to getOptions()
as there are some cases where we do want to be able to invite these users.
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.
There are already separate flags, we could reuse them or add a separate flag?
App/src/libs/OptionsListUtils.js
Lines 325 to 327 in 95bf36d
excludeConcierge = false, | |
excludeChronos = false, | |
excludeReceipts = false, |
- If we are going to reuse, then modify the line
App/src/libs/OptionsListUtils.js
Line 512 in 95bf36d
&& (!_.find(loginOptionsToExclude, loginOptionToExclude => loginOptionToExclude.login === searchValue))
as follows,
&& (!_.find(loginOptionsToExclude, loginOptionToExclude => loginOptionToExclude.login.toLowerCase() === searchValue.toLowerCase()))
- If we are going to add a separate boolean
shouldInviteExpensifyEmails
with default value asfalse
(if we want to go with the defaulttrue
we change the below line accordingly)
&& (!shouldInviteExpensifyEmails && !_.contains(CONST.EXPENSIFY_EMAILS, searchValue.toLowerCase()))
Either way, we can just remove the isExcludedIOUUsers
method.
What can we do here?
@marcaaron post your thoughts, I'll update PR, once you are okay with the proposed changes!
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.
Oh hmm... well if they are already excluded from the list of options then it seems reasonable to also not allow them to be returned as the userToInvite
.
If we are going to reuse, then modify the line
I'm confused now. So there is already logic to exclude them but why are they are not getting excluded? Why do they show in the list then? 😦
Ok to make this a bit more complicated (lol) it looks like there is already an array of "automated" expensify emails that was recently added in this other PR...
I think we should maybe discuss back in the issue how to handle this. Given that there are also only emails that we may want to exclude I think we should put this back into the proposal state and maybe pause this PR review to get some more feedback from others.
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.
I'm confused now. So there is already logic to exclude them but why are they are not getting excluded? Why do they show in the list then? 😦
Because we do only===
not check without about case sensitivity
Check with the current staging app, search receipts@expensify.com
it won't show upresults. But search Receipts@expensify.com
it will show up
with existing options, this should work the below solution will work
&& (!_.find(loginOptionsToExclude, loginOptionToExclude => loginOptionToExclude.login.toLowerCase() === searchValue.toLowerCase()))
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 I checked on main
branch. The bug we are "fixing" seems already fixed. Putting this PR on hold.
We can fix the casing issue, but that's not what we set out to do (and is a minor detail of the larger issue presented). So let's discuss how to proceed on the issue? Thanks!
Closing, Since this PR is no longer required! |
@marcaaron
Details
Just excluded bot accounts from IOU Participants Search Results
Fixed Issues
$ #4413
Tests & QA Steps
Note: Chronos/Receipts may appear in recent items - it will be handled in another issue check issue description for more.
Tested On
Screenshots
Screenshots for all platforms tested. Pull requests won't be merged unless the screenshots show the app was tested on all platforms.-->
Desktop
Web
Mobile Web
iOS
Android