diff --git a/src/components/Reactions/ReportActionItemEmojiReactions.js b/src/components/Reactions/ReportActionItemEmojiReactions.js index 57e901bf3cdc..7102f9982f52 100644 --- a/src/components/Reactions/ReportActionItemEmojiReactions.js +++ b/src/components/Reactions/ReportActionItemEmojiReactions.js @@ -67,72 +67,88 @@ function ReportActionItemEmojiReactions(props) { return (oldestUserReactionTimestamp || emojiReaction.createdAt) + emojiName; }); - return ( - - {_.map(sortedReactions, (reaction) => { - const reactionEmojiName = reaction.emojiName; - const usersWithReactions = _.pick(reaction.users, _.identity); - let reactionCount = 0; + const formattedReactions = _.map(sortedReactions, (reaction) => { + const reactionEmojiName = reaction.emojiName; + const usersWithReactions = _.pick(reaction.users, _.identity); + let reactionCount = 0; - // Loop through the users who have reacted and see how many skintones they reacted with so that we get the total count - _.forEach(usersWithReactions, (user) => { - reactionCount += _.size(user.skinTones); - }); - if (!reactionCount) { - return null; - } - totalReactionCount += reactionCount; - const emojiAsset = EmojiUtils.findEmojiByName(reactionEmojiName); - const emojiCodes = EmojiUtils.getUniqueEmojiCodes(emojiAsset, reaction.users); - const hasUserReacted = Report.hasAccountIDEmojiReacted(props.currentUserPersonalDetails.accountID, reaction.users); - const reactionUsers = _.keys(usersWithReactions); - const reactionUserAccountIDs = _.map(reactionUsers, Number); + // Loop through the users who have reacted and see how many skintones they reacted with so that we get the total count + _.forEach(usersWithReactions, (user) => { + reactionCount += _.size(user.skinTones); + }); + if (!reactionCount) { + return null; + } + totalReactionCount += reactionCount; + const emojiAsset = EmojiUtils.findEmojiByName(reactionEmojiName); + const emojiCodes = EmojiUtils.getUniqueEmojiCodes(emojiAsset, reaction.users); + const hasUserReacted = Report.hasAccountIDEmojiReacted(props.currentUserPersonalDetails.accountID, reaction.users); + const reactionUsers = _.keys(usersWithReactions); + const reactionUserAccountIDs = _.map(reactionUsers, Number); - const onPress = () => { - props.toggleReaction(emojiAsset); - }; + const onPress = () => { + props.toggleReaction(emojiAsset); + }; - const onReactionListOpen = (event) => { - reactionListRef.current.showReactionList(event, popoverReactionListAnchor.current, reaction); - }; + const onReactionListOpen = (event) => { + reactionListRef.current.showReactionList(event, popoverReactionListAnchor.current, reaction); + }; - return ( - ( - - )} - renderTooltipContentKey={[..._.map(reactionUsers, (user) => user.toString()), ...emojiCodes]} - key={reactionEmojiName} - > - - - - - ); - })} - {totalReactionCount > 0 && ( + return { + reactionEmojiName, + emojiCodes, + reactionUserAccountIDs, + onPress, + reactionUsers, + reactionCount, + hasUserReacted, + onReactionListOpen, + }; + }); + + return ( + totalReactionCount > 0 && ( + + {_.map(formattedReactions, (reaction) => { + if (reaction === null) { + return; + } + return ( + ( + + )} + renderTooltipContentKey={[..._.map(reaction.reactionUsers, (user) => user.toString()), ...reaction.emojiCodes]} + key={reaction.reactionEmojiName} + > + + + + + ); + })} - )} - + + ) ); }