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,17 @@ ); } +function useThreadInChatList(threadInfo: ?ThreadInfo): boolean { + const threadIsVisible = useThreadHasPermission( + threadInfo, + threadPermissions.VISIBLE, + ); + return React.useMemo( + () => viewerIsMember(threadInfo) && threadIsVisible, + [threadInfo, threadIsVisible], + ); +} + function threadIsTopLevel(threadInfo: ?(RawThreadInfo | ThreadInfo)): boolean { return threadInChatList(threadInfo) && threadIsChannel(threadInfo); } @@ -1918,6 +1929,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 =