diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js --- a/lib/shared/thread-utils.js +++ b/lib/shared/thread-utils.js @@ -201,6 +201,14 @@ ); } +function useThreadInChatList(threadInfo: ?ThreadInfo): boolean { + const threadIsVisible = useThreadHasPermission( + threadInfo, + threadPermissions.VISIBLE, + ); + return viewerIsMember(threadInfo) && threadIsVisible; +} + function threadIsTopLevel(threadInfo: ?(RawThreadInfo | ThreadInfo)): boolean { return threadInChatList(threadInfo) && threadIsChannel(threadInfo); } @@ -1910,6 +1918,7 @@ useThreadHasPermission, viewerIsMember, threadInChatList, + useThreadInChatList, threadIsTopLevel, threadIsChannel, threadIsSidebar, diff --git a/web/chat/thread-list-provider.js b/web/chat/thread-list-provider.js --- a/web/chat/thread-list-provider.js +++ b/web/chat/thread-list-provider.js @@ -12,10 +12,10 @@ import { threadInBackgroundChatList, threadInHomeChatList, - threadInChatList, getThreadListSearchResults, useThreadListSearch, threadIsPending, + useThreadInChatList, } from 'lib/shared/thread-utils.js'; import { threadTypes } from 'lib/types/thread-types-enum.js'; @@ -66,9 +66,8 @@ (activeTab === 'Focus' && activeTopLevelThreadIsFromHomeTab) || (activeTab === 'Background' && !activeTopLevelThreadIsFromHomeTab); - const activeTopLevelThreadIsInChatList = React.useMemo( - () => threadInChatList(activeTopLevelThreadInfo), - [activeTopLevelThreadInfo], + const activeTopLevelThreadIsInChatList = useThreadInChatList( + activeTopLevelThreadInfo, ); const shouldChangeTab =