diff --git a/lib/shared/edit-messages-utils.js b/lib/shared/edit-messages-utils.js --- a/lib/shared/edit-messages-utils.js +++ b/lib/shared/edit-messages-utils.js @@ -2,7 +2,7 @@ import * as React from 'react'; -import { threadHasPermission, threadIsPending } from './thread-utils.js'; +import { threadIsPending, useThreadHasPermission } from './thread-utils.js'; import { sendEditMessageActionTypes, useSendEditMessage, @@ -55,6 +55,13 @@ targetMessageInfo: ComposableMessageInfo | RobotextMessageInfo, ): boolean { const currentUserInfo = useSelector(state => state.currentUserInfo); + const currentUserCanEditMessage = useThreadHasPermission( + threadInfo, + threadPermissions.EDIT_MESSAGE, + ); + if (!currentUserCanEditMessage) { + return false; + } if (targetMessageInfo.type !== messageTypes.TEXT) { return false; @@ -66,15 +73,8 @@ const currentUserId = currentUserInfo.id; const targetMessageCreatorId = targetMessageInfo.creator.id; - if (currentUserId !== targetMessageCreatorId) { - return false; - } - const hasPermission = threadHasPermission( - threadInfo, - threadPermissions.EDIT_MESSAGE, - ); - return hasPermission; + return currentUserId === targetMessageCreatorId; } function getMessageLabel(hasBeenEdited: ?boolean, threadID: string): ?string {