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] Excluded Concierge, Chronos and receipts from IOU Requests search #4504

Conversation

Santhosh-Sellavel
Copy link
Collaborator

@Santhosh-Sellavel Santhosh-Sellavel commented Aug 7, 2021

@marcaaron

Details

Just excluded bot accounts from IOU Participants Search Results

Fixed Issues

$ #4413

Tests & QA Steps

  1. Search any of the following emails on the IOU request/split participants page.
 CHRONOS - 'chronos@expensify.com',
 CONCIERGE - 'concierge@expensify.com',
 RECEIPTS - 'receipts@expensify.com',
  1. Fix - In search results, the above emails will not appear now.

Note: Chronos/Receipts may appear in recent items - it will be handled in another issue check issue description for more.

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Screenshots for all platforms tested. Pull requests won't be merged unless the screenshots show the app was tested on all platforms.-->

Desktop

Screenshot 2021-08-18 at 12 03 47 AM

Screenshot 2021-08-18 at 12 04 21 AM

Screenshot 2021-08-18 at 12 04 09 AM

Web

Screenshot 2021-08-18 at 12 10 11 AM

Screenshot 2021-08-18 at 12 10 42 AM

Screenshot 2021-08-18 at 12 10 23 AM

Mobile Web

Simulator Screen Shot - iPhone 11 - 2021-08-18 at 00 14 19
Simulator Screen Shot - iPhone 11 - 2021-08-18 at 00 12 26
Simulator Screen Shot - iPhone 11 - 2021-08-18 at 00 12 40

iOS

Simulator Screen Shot - iPhone 12 - 2021-08-18 at 00 58 58
Simulator Screen Shot - iPhone 12 - 2021-08-18 at 00 58 50
Simulator Screen Shot - iPhone 12 - 2021-08-18 at 00 58 38

Android

Screenshot_1629228764
Screenshot_1629228775
Screenshot_1629228787

@Santhosh-Sellavel Santhosh-Sellavel marked this pull request as ready for review August 17, 2021 20:08
@Santhosh-Sellavel Santhosh-Sellavel requested a review from a team as a code owner August 17, 2021 20:08
@MelvinBot MelvinBot requested review from marcaaron and removed request for a team August 17, 2021 20:08
@Santhosh-Sellavel
Copy link
Collaborator Author

Santhosh-Sellavel commented Aug 20, 2021

@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.

@Santhosh-Sellavel Santhosh-Sellavel marked this pull request as draft August 20, 2021 18:24
@Santhosh-Sellavel
Copy link
Collaborator Author

I Have tested it once again & all checks are passed marking it ready for review.

@Santhosh-Sellavel Santhosh-Sellavel marked this pull request as ready for review August 20, 2021 21:29
Copy link
Contributor

@marcaaron marcaaron left a 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.

@@ -307,6 +307,25 @@ function isCurrentUser(userDetails) {
return result;
}

/**
* Returns whether the given userDetails is excluded from IOU request
* @param {Objecy} userDetails
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo Object

/**
* Returns whether the given userDetails is excluded from IOU request
* @param {Objecy} userDetails
* @returns {Bool}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean


if (userDetails && userDetails.login) {
const login = userDetails.login.toLowerCase();
return login === CONST.EMAIL.CHRONOS || login === CONST.EMAIL.CONCIERGE || login === CONST.EMAIL.RECEIPTS;
Copy link
Contributor

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);

Copy link
Collaborator Author

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 ?

Copy link
Contributor

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()

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Collaborator Author

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!

Copy link
Contributor

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,
    ];
}

Copy link
Collaborator Author

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,
        ];
    },

@Santhosh-Sellavel
Copy link
Collaborator Author

Working on the request changes

@Santhosh-Sellavel
Copy link
Collaborator Author

@marcaaron Requested changes have been updated.

Copy link
Contributor

@marcaaron marcaaron left a 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)) {
Copy link
Contributor

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:

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.

Copy link
Collaborator Author

@Santhosh-Sellavel Santhosh-Sellavel Aug 24, 2021

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?

excludeConcierge = false,
excludeChronos = false,
excludeReceipts = false,

  1. If we are going to reuse, then modify the line
    && (!_.find(loginOptionsToExclude, loginOptionToExclude => loginOptionToExclude.login === searchValue))

    as follows,
 && (!_.find(loginOptionsToExclude, loginOptionToExclude => loginOptionToExclude.login.toLowerCase() === searchValue.toLowerCase())) 
  1. If we are going to add a separate boolean shouldInviteExpensifyEmails with default value as false (if we want to go with the default true 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!

Copy link
Contributor

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...

https://github.com/Expensify/App/pull/4755/files#diff-9d6b0cc89c7cab66ac4042ac0549bfc66ddc9e7a182b6b5dbbf7f687328f10b5R264-R399

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.

Copy link
Collaborator Author

@Santhosh-Sellavel Santhosh-Sellavel Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcaaron

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()))

Copy link
Contributor

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!

@marcaaron marcaaron changed the title Excluded Concierge, Chronos and receipts from IOU Requests search [HOLD] Excluded Concierge, Chronos and receipts from IOU Requests search Aug 24, 2021
@Santhosh-Sellavel
Copy link
Collaborator Author

Closing, Since this PR is no longer required!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants