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 @@ -889,19 +889,12 @@ return encodedUpdatedPermissions; } -function threadIsWithBlockedUserOnly( - threadInfo: LegacyRawThreadInfo | RawThreadInfo, +function baseThreadIsWithBlockedUserOnly( + threadInfo: LegacyRawThreadInfo | RawThreadInfo | ThreadInfo, viewerID: ?string, userInfos: UserInfos, checkOnlyViewerBlock: boolean, -): boolean { - if ( - threadOrParentThreadIsGroupChat(threadInfo) || - threadOrParentThreadHasAdminRole(threadInfo) - ) { - return false; - } - +) { const otherUserID = getSingleOtherUser(threadInfo, viewerID); if (!otherUserID) { return false; @@ -921,32 +914,40 @@ ); } -function threadIsWithBlockedUserOnlyWithoutAdminRoleCheck( - threadInfo: ThreadInfo, +function threadIsWithBlockedUserOnly( + threadInfo: LegacyRawThreadInfo | RawThreadInfo, viewerID: ?string, userInfos: UserInfos, checkOnlyViewerBlock: boolean, ): boolean { - if (threadOrParentThreadIsGroupChat(threadInfo)) { + if ( + threadOrParentThreadIsGroupChat(threadInfo) || + threadOrParentThreadHasAdminRole(threadInfo) + ) { return false; } + return baseThreadIsWithBlockedUserOnly( + threadInfo, + viewerID, + userInfos, + checkOnlyViewerBlock, + ); +} - const otherUserID = getSingleOtherUser(threadInfo, viewerID); - if (!otherUserID) { +function threadIsWithBlockedUserOnlyWithoutAdminRoleCheck( + threadInfo: ThreadInfo, + viewerID: ?string, + userInfos: UserInfos, + checkOnlyViewerBlock: boolean, +): boolean { + if (threadOrParentThreadIsGroupChat(threadInfo)) { return false; } - const otherUserRelationshipStatus = - userInfos[otherUserID]?.relationshipStatus; - - if (checkOnlyViewerBlock) { - return ( - otherUserRelationshipStatus === userRelationshipStatus.BLOCKED_BY_VIEWER - ); - } - - return ( - !!otherUserRelationshipStatus && - relationshipBlockedInEitherDirection(otherUserRelationshipStatus) + return baseThreadIsWithBlockedUserOnly( + threadInfo, + viewerID, + userInfos, + checkOnlyViewerBlock, ); }