diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 4afa797312021..5a3ff789b1955 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -893,6 +893,7 @@ function createOption( isSelfDM: report ? reportUtilsIsSelfDM(report) : false, isChatRoom: report ? reportUtilsIsChatRoom(report) : false, isInvoiceRoom: report ? isInvoiceRoom(report) : false, + isDM: report ? isDM(report) : false, // Status properties - used in SearchOption context private_isArchived: undefined, // Set from reportNameValuePairs below @@ -1845,6 +1846,7 @@ function isValidReport(option: SearchOption, config: IsValidReportsConfi excludeNonAdminWorkspaces, isRestrictedToPreferredPolicy, preferredPolicyID, + shouldAlwaysIncludeDM, } = config; const topmostReportId = Navigation.getTopmostReportId(); @@ -1940,7 +1942,7 @@ function isValidReport(option: SearchOption, config: IsValidReportsConfi - It doesn't have a login - It is not an invoice room that should be shown */ - if (!isCurrentUserOwnedPolicyExpenseChatThatCouldShow && !includeMultipleParticipantReports && !option.login && !shouldShowInvoiceRoom) { + if (!isCurrentUserOwnedPolicyExpenseChatThatCouldShow && !includeMultipleParticipantReports && !option.login && (!option.isDM || !shouldAlwaysIncludeDM) && !shouldShowInvoiceRoom) { return false; } diff --git a/src/libs/OptionsListUtils/types.ts b/src/libs/OptionsListUtils/types.ts index 814cc47f115e8..e56b75130757f 100644 --- a/src/libs/OptionsListUtils/types.ts +++ b/src/libs/OptionsListUtils/types.ts @@ -68,6 +68,7 @@ type SearchOptionData = Pick< | 'isChatRoom' | 'isInvoiceRoom' | 'isDefaultRoom' + | 'isDM' // Status properties | 'private_isArchived' @@ -155,6 +156,7 @@ type GetValidReportsConfig = { isRestrictedToPreferredPolicy?: boolean; preferredPolicyID?: string; shouldUnreadBeBold?: boolean; + shouldAlwaysIncludeDM?: boolean; } & GetValidOptionsSharedConfig; type IsValidReportsConfig = Pick< @@ -176,6 +178,7 @@ type IsValidReportsConfig = Pick< | 'excludeNonAdminWorkspaces' | 'isRestrictedToPreferredPolicy' | 'preferredPolicyID' + | 'shouldAlwaysIncludeDM' >; type GetOptionsConfig = { diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 4bc3e042d7800..4f0c6cbaa37b1 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -862,6 +862,7 @@ type OptionData = { isDefaultRoom?: boolean; isInvoiceRoom?: boolean; isExpenseReport?: boolean; + isDM?: boolean; isOptimisticPersonalDetail?: boolean; selected?: boolean; isOptimisticAccount?: boolean; diff --git a/src/pages/NewChatPage.tsx b/src/pages/NewChatPage.tsx index 52e05cf17f1dd..ecc0d103beeab 100755 --- a/src/pages/NewChatPage.tsx +++ b/src/pages/NewChatPage.tsx @@ -100,6 +100,7 @@ function useOptions() { { betas: betas ?? [], includeSelfDM: true, + shouldAlwaysIncludeDM: true, }, countryCode, ); @@ -342,6 +343,7 @@ function NewChatPage({ref}: NewChatPageProps) { Navigation.dismissModalWithReport({reportID: option.reportID}); return; } + if (selectedOptions.length && option) { // Prevent excluded emails from being added to groups if (option?.login && excludedGroupEmails.has(option.login)) { @@ -351,6 +353,15 @@ function NewChatPage({ref}: NewChatPageProps) { return; } + if (option?.reportID) { + Navigation.dismissModal({ + callback: () => { + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(option?.reportID)); + }, + }); + return; + } + let login = ''; if (option?.login) { @@ -371,7 +382,7 @@ function NewChatPage({ref}: NewChatPageProps) { const itemRightSideComponent = useCallback( (item: ListItem & Option, isFocused?: boolean) => { - if (!!item.isSelfDM || (item.login && excludedGroupEmails.has(item.login))) { + if (!!item.isSelfDM || (item.login && excludedGroupEmails.has(item.login)) || !item.login) { return null; }