From d053555283ed45175b964efa630959a519db7e18 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Wed, 2 Oct 2024 15:14:10 -0700 Subject: [PATCH] ensure we only access emojiCode for indices greater than 0 --- src/libs/EmojiUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/EmojiUtils.ts b/src/libs/EmojiUtils.ts index 493837ca023b..7c042bbefe67 100644 --- a/src/libs/EmojiUtils.ts +++ b/src/libs/EmojiUtils.ts @@ -462,7 +462,7 @@ const getPreferredSkinToneIndex = (value: OnyxEntry): number => */ const getPreferredEmojiCode = (emoji: Emoji, preferredSkinTone: OnyxEntry): string => { if (emoji.types && typeof preferredSkinTone === 'number') { - const emojiCodeWithSkinTone = emoji.types.at(preferredSkinTone); + const emojiCodeWithSkinTone = preferredSkinTone >= 0 ? emoji.types.at(preferredSkinTone) : undefined; // Note: it can happen that preferredSkinTone has a outdated format, // so it makes sense to check if we actually got a valid emoji code back