@@ -277,6 +277,36 @@ function isSearchStringMatch(searchValue, searchText, participantNames = new Set
277
277
} ) ;
278
278
}
279
279
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
+
280
310
/**
281
311
* Build the options
282
312
*
@@ -476,6 +506,7 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, {
476
506
if ( searchValue
477
507
&& recentReportOptions . length === 0
478
508
&& personalDetailsOptions . length === 0
509
+ && ! isCurrentUser ( { login : searchValue } )
479
510
&& _ . every ( selectedOptions , option => option . login !== searchValue )
480
511
&& ( ( Str . isValidEmail ( searchValue ) && ! Str . isDomainEmail ( searchValue ) ) || Str . isValidPhone ( searchValue ) )
481
512
&& ( ! _ . find ( loginOptionsToExclude , loginOptionToExclude => loginOptionToExclude . login === searchValue ) )
@@ -751,38 +782,9 @@ function getReportIcons(report, personalDetails) {
751
782
. map ( item => item . avatar ) ;
752
783
}
753
784
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
-
784
785
export {
785
786
addSMSDomainIfPhoneNumber ,
787
+ isCurrentUser ,
786
788
getSearchOptions ,
787
789
getNewChatOptions ,
788
790
getNewGroupOptions ,
@@ -794,5 +796,4 @@ export {
794
796
getIOUConfirmationOptionsFromParticipants ,
795
797
getDefaultAvatar ,
796
798
getReportIcons ,
797
- isCurrentUser ,
798
799
} ;
0 commit comments