diff --git a/src/CONST.ts b/src/CONST.ts index 8e240ac43ca1..0b8898f2fbfd 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -2910,10 +2910,6 @@ const CONST = { get RESTRICTED_ACCOUNT_IDS() { return [this.ACCOUNT_ID.NOTIFICATIONS]; }, - // Account IDs that can't be added as a group member - get NON_ADDABLE_ACCOUNT_IDS() { - return [this.ACCOUNT_ID.NOTIFICATIONS, this.ACCOUNT_ID.CHRONOS]; - }, // Auth limit is 60k for the column but we store edits and other metadata along the html so let's use a lower limit to accommodate for it. MAX_COMMENT_LENGTH: 10000, diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 497a2d33cf56..1296a64e571d 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1893,7 +1893,7 @@ function getOptions( allPersonalDetailsOptions = lodashOrderBy(allPersonalDetailsOptions, [(personalDetail) => personalDetail.text?.toLowerCase()], 'asc'); } - const optionsToExclude: Option[] = []; + 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 diff --git a/src/pages/NewChatPage.tsx b/src/pages/NewChatPage.tsx index 13fbbc35b5da..c28290e353e7 100755 --- a/src/pages/NewChatPage.tsx +++ b/src/pages/NewChatPage.tsx @@ -34,13 +34,9 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {SelectedParticipant} from '@src/types/onyx/NewGroupChatDraft'; -type NewChatPageProps = { - isGroupChat?: boolean; -}; +const excludedGroupEmails: string[] = CONST.EXPENSIFY_EMAILS.filter((value) => value !== CONST.EMAIL.CONCIERGE); -const excludedGroupEmails = CONST.EXPENSIFY_EMAILS.filter((value) => value !== CONST.EMAIL.CONCIERGE); - -function useOptions({isGroupChat}: NewChatPageProps) { +function useOptions() { const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState(''); const [selectedOptions, setSelectedOptions] = useState>([]); const [betas] = useOnyx(ONYXKEYS.BETAS); @@ -57,22 +53,20 @@ function useOptions({isGroupChat}: NewChatPageProps) { personalDetails: listOptions.personalDetails ?? [], betas: betas ?? [], selectedOptions, - excludeLogins: isGroupChat ? excludedGroupEmails : [], maxRecentReportsToShow: 0, includeSelfDM: true, }); return filteredOptions; - }, [betas, isGroupChat, listOptions.personalDetails, listOptions.reports, selectedOptions]); + }, [betas, listOptions.personalDetails, listOptions.reports, selectedOptions]); const options = useMemo(() => { const filteredOptions = OptionsListUtils.filterOptions(defaultOptions, debouncedSearchTerm, { selectedOptions, - excludeLogins: isGroupChat ? excludedGroupEmails : [], maxRecentReportsToShow: CONST.IOU.MAX_RECENT_REPORTS_TO_SHOW, }); return filteredOptions; - }, [debouncedSearchTerm, defaultOptions, isGroupChat, selectedOptions]); + }, [debouncedSearchTerm, defaultOptions, selectedOptions]); const cleanSearchTerm = useMemo(() => debouncedSearchTerm.trim().toLowerCase(), [debouncedSearchTerm]); const headerMessage = useMemo(() => { return OptionsListUtils.getHeaderMessage( @@ -129,7 +123,7 @@ function useOptions({isGroupChat}: NewChatPageProps) { }; } -function NewChatPage({isGroupChat}: NewChatPageProps) { +function NewChatPage() { const {translate} = useLocalize(); const {isOffline} = useNetwork(); // We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to show offline indicator on small screen only @@ -142,9 +136,7 @@ function NewChatPage({isGroupChat}: NewChatPageProps) { const selectionListRef = useRef(null); const {headerMessage, searchTerm, debouncedSearchTerm, setSearchTerm, selectedOptions, setSelectedOptions, recentReports, personalDetails, userToInvite, areOptionsInitialized} = - useOptions({ - isGroupChat, - }); + useOptions(); const [sections, firstKeyForList] = useMemo(() => { const sectionsList: OptionsListUtils.CategorySection[] = []; @@ -217,7 +209,7 @@ function NewChatPage({isGroupChat}: NewChatPageProps) { const itemRightSideComponent = useCallback( (item: ListItem & OptionsListUtils.Option, isFocused?: boolean) => { - if (!!item.isSelfDM || (item.accountID && CONST.NON_ADDABLE_ACCOUNT_IDS.includes(item.accountID))) { + if (!!item.isSelfDM || (item.login && excludedGroupEmails.includes(item.login))) { return null; } /**