diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 2aad4179c337..b9e62be19769 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1505,7 +1505,8 @@ function createOptionList(personalDetails: OnyxEntry, repor } function createOptionFromReport(report: Report, personalDetails: OnyxEntry) { - const accountIDs = report.participantAccountIDs ?? []; + const isSelfDM = ReportUtils.isSelfDM(report); + const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : report.participantAccountIDs ?? []; return { item: report, @@ -1740,8 +1741,7 @@ function getOptions( allPersonalDetailsOptions = lodashOrderBy(allPersonalDetailsOptions, [(personalDetail) => personalDetail.text?.toLowerCase()], 'asc'); } - // Exclude the current user from the personal details list - const optionsToExclude: Option[] = [{login: currentUserLogin}, {login: CONST.EMAIL.NOTIFICATIONS}]; + const optionsToExclude: Option[] = [{login: CONST.EMAIL.NOTIFICATIONS}]; // If we're including selected options from the search results, we only want to exclude them if the search input is empty // This is because on certain pages, we show the selected options at the top when the search input is empty @@ -1820,9 +1820,10 @@ function getOptions( } if (includePersonalDetails) { + const personalDetailsOptionsToExclude = [...optionsToExclude, {login: currentUserLogin}]; // Next loop over all personal details removing any that are selectedUsers or recentChats allPersonalDetailsOptions.forEach((personalDetailOption) => { - if (optionsToExclude.some((optionToExclude) => optionToExclude.login === personalDetailOption.login)) { + if (personalDetailsOptionsToExclude.some((optionToExclude) => optionToExclude.login === personalDetailOption.login)) { return; } const {searchText, participantsList, isChatRoom} = personalDetailOption; diff --git a/src/pages/NewChatPage.tsx b/src/pages/NewChatPage.tsx index 470afc28d76e..3f0c9a23da3f 100755 --- a/src/pages/NewChatPage.tsx +++ b/src/pages/NewChatPage.tsx @@ -68,6 +68,10 @@ function useOptions({isGroupChat}: NewChatPageProps) { {}, [], true, + undefined, + undefined, + undefined, + true, ); const maxParticipantsReached = selectedOptions.length === CONST.REPORT.MAXIMUM_PARTICIPANTS; @@ -182,6 +186,10 @@ function NewChatPage({isGroupChat}: NewChatPageProps) { */ const createChat = useCallback( (option?: OptionsListUtils.Option) => { + if (option?.isSelfDM) { + Navigation.dismissModal(option.reportID); + return; + } let login = ''; if (option?.login) { @@ -200,6 +208,9 @@ function NewChatPage({isGroupChat}: NewChatPageProps) { const itemRightSideComponent = useCallback( (item: ListItem & OptionsListUtils.Option) => { + if (item.isSelfDM) { + return null; + } /** * Removes a selected option from list if already selected. If not already selected add this option to the list. * @param option