Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.57k stars 2.92k forks source link

[HOLD PR #47547] [$1000] Emoji size from email reply is smaller then emoji size sent via normal chat and emoji does not use user selected skin color #14753

Open kavimuru opened 1 year ago

kavimuru commented 1 year ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Open the app and login with user A
  2. Open user B chat and send a message
  3. Open user B email
  4. Reply to user A message by email and send only emojis

Expected Result:

Size of emojis sent via email reply should be same as size of emoji sent via normal chat, emoji skin color should also match to the one used by the user

Actual Result:

Size of emojis is smaller then size of emojis sent via normal chat and skin color too does not match

Workaround:

unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

Version Number: v1.2.63-0 Reproducible in staging?: y Reproducible in production?: y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos:

https://user-images.githubusercontent.com/43996225/216351996-a259a36c-cd7d-4260-9e78-79d3714f275e.mp4

https://user-images.githubusercontent.com/43996225/216352049-c590c637-ddfb-46e4-9696-e002ff6bb357.mp4

Expensify/Expensify Issue URL: Issue reported by: @dhanashree-sawant Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1675272531555829

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0174e50816828c7960
  • Upwork Job ID: 1622671435996983296
  • Last Price Increase: 2023-02-06
melvin-bot[bot] commented 1 year ago

Triggered auto assignment to @mallenexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

melvin-bot[bot] commented 1 year ago

Bug0 Triage Checklist (Main S/O)

mallenexpensify commented 1 year ago

Testing, not getting emails for all chats sent from my test account.

MelvinBot commented 1 year ago

@mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

mallenexpensify commented 1 year ago

ah ha! Was able to reproduce, nice find @dhanashree-sawant Pretty sure this can be external.

MelvinBot commented 1 year ago

Job added to Upwork: https://www.upwork.com/jobs/~0174e50816828c7960

MelvinBot commented 1 year ago

Current assignee @mallenexpensify is eligible for the External assigner, not assigning anyone new.

MelvinBot commented 1 year ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav (External)

MelvinBot commented 1 year ago

Triggered auto assignment to @pecanoro (External), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

Prince-Mendiratta commented 1 year ago

Proposal

RCA

Whenever a comment is sent from the email, the update is of this format -

[{"onyxMethod":"merge","key":"report_7264088055740850","value":{"reportID":"7264088055740850","maxSequenceNumber":49,"lastActionCreated":"2023-02-06 21:10:18.038","lastReadTime":"2023-02-06 21:10:08.928","lastMessageText":"πŸ‘΄πŸ‘΄","lastActorEmail":"expertsquarrel@gmail.com"}},{"onyxMethod":"merge","key":"reportActions_7264088055740850","value":{"49":{"person":[{"type":"TEXT","style":"strong","text":"expert"}],"actorEmail":"expertsquarrel@gmail.com","actorAccountID":13064488,"message":[{"type":"COMMENT","html":"<div dir=\"ltr\">πŸ‘΄πŸ‘΄</div>","text":"πŸ‘΄πŸ‘΄","isEdited":false}],"originalMessage":{"html":"<div dir=\"ltr\">πŸ‘΄πŸ‘΄</div>","source":"email"},"avatar":"https://d1wpcgnaa73g0y.cloudfront.net/497a9e0151014341987046ea878258b3833ec0b7_128.jpeg","created":"2023-02-06 21:10:18.038","timestamp":1675717818,"reportActionTimestamp":1675717818038,"automatic":false,"sequenceNumber":49,"actionName":"ADDCOMMENT","shouldShow":true,"clientID":"","reportActionID":"7249547654175174326","isAttachment":false},"":null},"shouldNotify":true}]

From the backend, the emojis are enclosed with <div dir="ltr">{emojis}</div>. As per this code, we check if the text is to be rendered as HTML or Text component - https://github.com/Expensify/App/blob/37e93444ff414b7cb6de81933dbe194ce7f787fa/src/pages/home/report/ReportActionItemFragment.js#L101-L119

We only check for the existence of emoji only texts if the text is being rendered using the Text component and not as an HTML.

Solution

We can add conditions to check that if the text obtained from an email comment contains only emojis and if it does, apply the onlyEmojisText style to the element by enclosing it with a custom tag.

diff --git a/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js b/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js
index 456cd1ecf3..9402cd8314 100755
--- a/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js
+++ b/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js
@@ -35,6 +35,10 @@ const customHTMLElementModels = {
         tagName: 'comment',
         mixedUAStyles: {whiteSpace: 'pre'},
     }),
+    'emojis-only': defaultHTMLElementModels.div.extend({
+        tagName: 'emojis-only',
+        mixedUAStyles: {...styles.onlyEmojisText},
+    }),
     'email-comment': defaultHTMLElementModels.div.extend({
         tagName: 'email-comment',
         mixedUAStyles: {whiteSpace: 'normal'},

diff --git a/src/pages/home/report/ReportActionItemFragment.js b/src/pages/home/report/ReportActionItemFragment.js
index c4f593517d..a700b2a0e4 100644
--- a/src/pages/home/report/ReportActionItemFragment.js
+++ b/src/pages/home/report/ReportActionItemFragment.js
@@ -108,7 +108,8 @@ const ReportActionItemFragment = (props) => {
             // Only render HTML if we have html in the fragment
             if (!differByLineBreaksOnly) {
                 const editedTag = props.fragment.isEdited ? '<edited></edited>' : '';
-                const htmlContent = html + editedTag;
+                const emojiOnlyTag = EmojiUtils.containsOnlyEmojis(text) ? `<emojis-only>${html}</emojis-only>` : html;
+                const htmlContent = emojiOnlyTag + editedTag;
                 return (
                     <RenderHTML
                         html={props.source === 'email'

Regarding the emoji skin color issue, I believe it is not a bug and we should not handle that. When a user responds using email, they have specifically used the default emoji tone. If they were to instead use custom emoji skin colors, such as πŸ–πŸ»πŸ–πŸΏπŸ–πŸ», then when it renders in expensify, it renders correctly as πŸ–πŸ»πŸ–πŸΏπŸ–πŸ». If were to instead change all the emojis to the default skin color of the user, it would convert it to πŸ–πŸ»πŸ–πŸ»πŸ–πŸ», if the default tone was white. This would lead to a loss of information and the best way to deal with this is to do nothing. If the user chooses to send default skin tone, then we display default skin tone.

Results

https://user-images.githubusercontent.com/54077356/217096550-3b4b836e-655d-4abd-b25b-f175e58815f0.mp4

Prince-Mendiratta commented 1 year ago

Proposal 2

Solution

We can simply check if the text contains only emojis. If it does, then display it using Text instead. The result is same as in my above proposal.

diff --git a/src/pages/home/report/ReportActionItemFragment.js b/src/pages/home/report/ReportActionItemFragment.js
index c4f593517d..3e4cb3915b 100644
--- a/src/pages/home/report/ReportActionItemFragment.js
+++ b/src/pages/home/report/ReportActionItemFragment.js
@@ -106,7 +106,7 @@ const ReportActionItemFragment = (props) => {
             const differByLineBreaksOnly = Str.replaceAll(html, '<br />', '\n') === text;

             // Only render HTML if we have html in the fragment
-            if (!differByLineBreaksOnly) {
+            if (!differByLineBreaksOnly && !EmojiUtils.containsOnlyEmojis(text)) {
                 const editedTag = props.fragment.isEdited ? '<edited></edited>' : '';
                 const htmlContent = html + editedTag;
                 return (

Proposal 3

Why are we adding the extra div in the backend? I'd say we can directly remove the div from the backend since then the component would use the Text component and it applies the ltr style anyways.

s77rt commented 1 year ago

Proposal

diff --git a/src/pages/home/report/ReportActionItemFragment.js b/src/pages/home/report/ReportActionItemFragment.js
index c4f593517d..b4ced62e10 100644
--- a/src/pages/home/report/ReportActionItemFragment.js
+++ b/src/pages/home/report/ReportActionItemFragment.js
@@ -104,9 +104,10 @@ const ReportActionItemFragment = (props) => {
             // we render it as text, not as html.
             // This is done to render emojis with line breaks between them as text.
             const differByLineBreaksOnly = Str.replaceAll(html, '<br />', '\n') === text;
+            const differByDivTagsOnly = Str.replaceAll(html, /<div[^>]*>|<\/div>/g, '') === text;

             // Only render HTML if we have html in the fragment
-            if (!differByLineBreaksOnly) {
+            if (!differByLineBreaksOnly && !differByDivTagsOnly) {
                 const editedTag = props.fragment.isEdited ? '<edited></edited>' : '';
                 const htmlContent = html + editedTag;
                 return (

RCA

Sending messages from email will most likely be sent as html and that's the case here where emojis are sent as <div dir="ltr">😁</div>. Since the message is technically html it will be rendered using our HTML render engine. However as you can see there is nothing special about that message to treat it as html and we can instead just treat as a text.

We follow this approach in another similar case where the difference between the html message and the plaintext message is just line breaks (differByLineBreaksOnly) and I propose to do the same here by checking if the difference between the two messages is just those "useless" div tags (differByDivTagsOnly).

So, we strip the html message from those useless div tags and if it's the same as the text then just treat it as text.


bernhardoj commented 1 year ago

I think this issue will eventually be fixed by this improvement.

pecanoro commented 1 year ago

@bernhardoj I think you are right. That issue encompasses a lot of fixes for emojis by making them consistent so I am going to add a HOLD on this one in benefit of that one. @mananjadhav What do you think? Or do you think we should fix this one separately?

mananjadhav commented 1 year ago

I can't make out if the email issue will be resolved, but we should hold this one anyway. The linked issue doesn't have any proposals so far, and I am fairly confident proposals will include some logic to match emoji, etc.

So yeah let's hold this one @pecanoro

pecanoro commented 1 year ago

Still on HOLD

pecanoro commented 1 year ago

Still on HOLD waiting for https://github.com/Expensify/App/pull/15088

mallenexpensify commented 1 year ago

The updated PR link we're waiting on is https://github.com/Expensify/App/pull/15611 (long story)

pecanoro commented 1 year ago

Still waiting on https://github.com/Expensify/App/pull/15611

pecanoro commented 1 year ago

Still waiting on https://github.com/Expensify/App/pull/15611

pecanoro commented 1 year ago

Still waiting on https://github.com/Expensify/App/pull/15611

pecanoro commented 1 year ago

Still waiting on https://github.com/Expensify/App/pull/15611

pecanoro commented 1 year ago

Posted here asking why the PR is on HOLD to see what we should do.

pecanoro commented 1 year ago

Still waiting on https://github.com/Expensify/App/pull/15611

mallenexpensify commented 1 year ago

Till holding on https://github.com/Expensify/App/pull/15611

mallenexpensify commented 1 year ago

Still holding

mallenexpensify commented 1 year ago

We're waiting on https://github.com/Expensify/App/pull/15611 which is waiting on https://github.com/facebook/hermes/issues/932#issuecomment-1714399174 which will be live in v.73 https://reactnative.dev/versions

mallenexpensify commented 1 year ago

^ Same

pecanoro commented 11 months ago

Ohh it seems we finally have a new version! I am going to post in the PR!

pecanoro commented 10 months ago

Posted again here to figure out the next steps.

mananjadhav commented 9 months ago

The held issue was now assigned and I've posted a comment here.

mallenexpensify commented 8 months ago

Issue we're held on is actively being worked on

mallenexpensify commented 8 months ago

@mananjadhav can you take a look here?

I'm wondering if we can take this off hold, it looks like the associated PR was merged

mananjadhav commented 7 months ago

@mallenexpensify The associated PR is not merged. https://github.com/Expensify/App/pull/37980 I think the linked issue's PR was dependent on the one you linked in the previous comment. This should still be on hold.

mallenexpensify commented 7 months ago

Thanks @mananjadhav , updated the title to correctly reflect the PR we're held on.

pecanoro commented 7 months ago

I bumped the PR that we are holding on since it was a bit stale

pecanoro commented 6 months ago

It seems there has been some progress in the PR we are holding onto: https://github.com/Expensify/App/pull/40692

pecanoro commented 5 months ago

Same update as last time, the PR is still in progress

pecanoro commented 4 months ago

Ohh https://github.com/Expensify/App/pull/40692 is close to getting merged!

pecanoro commented 3 months ago

https://github.com/Expensify/App/pull/40692 was finally merged! @mallenexpensify Could you check if this is still an issue or we can finally close it?

pecanoro commented 3 months ago

Oh nvm, it was reverted and now we are waiting on this: https://github.com/Expensify/App/pull/47547

mallenexpensify commented 1 month ago

Hold still

pecanoro commented 3 weeks ago

Hold still

mallenexpensify commented 2 days ago

Hit staging two hours ago https://github.com/Expensify/App/pull/47547#issuecomment-2494746041