diff --git a/native/user-profile/user-profile-relationship-button.react.js b/native/user-profile/user-profile-relationship-button.react.js --- a/native/user-profile/user-profile-relationship-button.react.js +++ b/native/user-profile/user-profile-relationship-button.react.js @@ -33,21 +33,26 @@ pendingPersonalThreadUserInfo, ); + const otherUserIsFriend = + !otherUserInfo || + !otherUserInfo.username || + otherUserInfo.relationshipStatus === userRelationshipStatus.FRIEND; + + const otherUserSentFriendRequest = + otherUserInfo?.relationshipStatus === + userRelationshipStatus.REQUEST_RECEIVED; + + const viewerSentFriendRequest = + otherUserInfo?.relationshipStatus === userRelationshipStatus.REQUEST_SENT; + const styles = useStyles(unboundStyles); const userProfileRelationshipButton = React.useMemo(() => { - if ( - !otherUserInfo || - !otherUserInfo.username || - otherUserInfo.relationshipStatus === userRelationshipStatus.FRIEND - ) { + if (otherUserIsFriend) { return null; } - if ( - otherUserInfo.relationshipStatus === - userRelationshipStatus.REQUEST_RECEIVED - ) { + if (otherUserSentFriendRequest) { return ( @@ -65,9 +70,7 @@ ); } - if ( - otherUserInfo.relationshipStatus === userRelationshipStatus.REQUEST_SENT - ) { + if (viewerSentFriendRequest) { return ( @@ -81,14 +84,16 @@ ); }, [ - friendUser, - otherUserInfo, - styles.acceptFriendRequestButtonContainer, - styles.incomingFriendRequestButtonsContainer, + otherUserIsFriend, + otherUserSentFriendRequest, + viewerSentFriendRequest, + styles.singleButtonContainer, styles.incomingFriendRequestContainer, styles.incomingFriendRequestLabel, + styles.incomingFriendRequestButtonsContainer, + styles.acceptFriendRequestButtonContainer, styles.rejectFriendRequestButtonContainer, - styles.singleButtonContainer, + friendUser, unfriendUser, ]);