Skip to content

Commit 064e582

Browse files
authored
Merge pull request #4647 from aman-atg/aman-atg-dontShowUserOnSearch
don't show user while searching
2 parents 0d263e5 + 1ae25f2 commit 064e582

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

src/libs/OptionsListUtils.js

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,36 @@ function isSearchStringMatch(searchValue, searchText, participantNames = new Set
277277
});
278278
}
279279

280+
/**
281+
* Returns the given userDetails is currentUser or not.
282+
* @param {Object} userDetails
283+
* @returns {Bool}
284+
*/
285+
286+
function isCurrentUser(userDetails) {
287+
if (!userDetails) {
288+
// If userDetails is null or undefined
289+
return false;
290+
}
291+
292+
// If user login is mobile number, append sms domain if not appended already just a fail safe.
293+
const userDetailsLogin = addSMSDomainIfPhoneNumber(userDetails.login);
294+
295+
// Initial check with currentUserLogin
296+
let result = currentUserLogin.toLowerCase() === userDetailsLogin.toLowerCase();
297+
const loginList = _.isEmpty(currentUser) || _.isEmpty(currentUser.loginList) ? [] : currentUser.loginList;
298+
let index = 0;
299+
300+
// Checking userDetailsLogin against to current user login options.
301+
while (index < loginList.length && !result) {
302+
if (loginList[index].partnerUserID.toLowerCase() === userDetailsLogin.toLowerCase()) {
303+
result = true;
304+
}
305+
index++;
306+
}
307+
return result;
308+
}
309+
280310
/**
281311
* Build the options
282312
*
@@ -476,6 +506,7 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, {
476506
if (searchValue
477507
&& recentReportOptions.length === 0
478508
&& personalDetailsOptions.length === 0
509+
&& !isCurrentUser({login: searchValue})
479510
&& _.every(selectedOptions, option => option.login !== searchValue)
480511
&& ((Str.isValidEmail(searchValue) && !Str.isDomainEmail(searchValue)) || Str.isValidPhone(searchValue))
481512
&& (!_.find(loginOptionsToExclude, loginOptionToExclude => loginOptionToExclude.login === searchValue))
@@ -751,38 +782,9 @@ function getReportIcons(report, personalDetails) {
751782
.map(item => item.avatar);
752783
}
753784

754-
/**
755-
* Returns the given userDetails is currentUser or not.
756-
* @param {Object} userDetails
757-
* @returns {Bool}
758-
*/
759-
760-
function isCurrentUser(userDetails) {
761-
if (!userDetails) {
762-
// If userDetails is null or undefined
763-
return false;
764-
}
765-
766-
// If user login is mobile number, append sms domain if not appended already just a fail safe.
767-
const userDetailsLogin = addSMSDomainIfPhoneNumber(userDetails.login);
768-
769-
// Initial check with currentUserLogin
770-
let result = currentUserLogin.toLowerCase() === userDetailsLogin.toLowerCase();
771-
const {loginList} = currentUser;
772-
let index = 0;
773-
774-
// Checking userDetailsLogin against to current user login options.
775-
while (index < loginList.length && !result) {
776-
if (loginList[index].partnerUserID.toLowerCase() === userDetailsLogin.toLowerCase()) {
777-
result = true;
778-
}
779-
index++;
780-
}
781-
return result;
782-
}
783-
784785
export {
785786
addSMSDomainIfPhoneNumber,
787+
isCurrentUser,
786788
getSearchOptions,
787789
getNewChatOptions,
788790
getNewGroupOptions,
@@ -794,5 +796,4 @@ export {
794796
getIOUConfirmationOptionsFromParticipants,
795797
getDefaultAvatar,
796798
getReportIcons,
797-
isCurrentUser,
798799
};

0 commit comments

Comments
 (0)