Skip to content

Formatting of email responses in NewDot isn't pretty #8088

Closed

Description

@mvtglobally

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:

@greeny was sending messages back/forth to a business partner

Expected Result:

When the partner replied via email that the formatting would like nice and there wouldn't be extra line breaks

Actual Result:

Formatting is a bit janky, inc. extra line breaks

Workaround:

unknown

Platform:

Where is this issue occurring?

  • Web
  • iOS
  • Android
  • Desktop App
  • Mobile Web

Version Number: 1.1.41-3
Reproducible in staging?: need repro
Reproducible in production?: Y
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
image - 2022-03-11T000521 922

Expensify/Expensify Issue URL:
Issue reported by: @mallenexpensify
Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1646931708047189

View all open jobs on GitHub

Activity

  1. MelvinBot commented on Mar 11, 2022

    @MelvinBot
    Contributor

    Triggered auto assignment to @MariaHCD (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

  2. MariaHCD commented on Mar 14, 2022

    @MariaHCD
    Contributor

    I think this could be an issue on the backend when parsing the response (and thus, possibly not something an external contributor could work on)

    @zsgreenwald Would you mind DM'ing me more details (eg. the user's email) so I can investigate further via the logs and possibly on Mailgun as well?

  3. zsgreenwald commented on Mar 14, 2022

    @zsgreenwald
    Contributor

    On it!

  4. MariaHCD commented on Mar 15, 2022

    @MariaHCD
    Contributor

    Looks like we ran into something similar here: https://github.com/Expensify/Expensify/issues/142335

    Looking at the logs for the user that @zsgreenwald sent over via DM, looks like we defaulted to mailgun's stripped HTML content instead of parsing it ourselves:

    Email request is either using VML/XML namespaces or is from an unknown provider, relying on mailgun's stripped HTML content

    cc: @thienlnam Not sure if we can do anything here?

  5. thienlnam commented on Mar 15, 2022

    @thienlnam
    Contributor

    Yeah, not much we can do here unless we try to strip it ourselves which leads to endless things we'd have to account for. Since mailgun email stripping has been unreliable we can look into using another library for this except we'd need to test multiple platforms to make sure it works and isn't stripping out text content. We can also strip out whitespace after stripped HTML but that also leads to some unintended changes in other email providers

  6. MariaHCD commented on Mar 16, 2022

    @MariaHCD
    Contributor

    Thanks, @thienlnam! So it sounds like:

    Option 1: Strip the content ourselves (which would be tricky due to the endless number of mail providers that we'd have to account for)

    Option 2: Investigate usage of another library (which would entail lots of tests across multiple platforms to ensure the text content isn't being stripped)

    Option 3:

    We can also strip out whitespace after stripped HTML but that also leads to some unintended changes in other email providers

    Could you elaborate on those unintended changes? Maybe we can trim any whitespaces before and after the stripped HTML?

  7. thienlnam commented on Mar 16, 2022

    @thienlnam
    Contributor

    Yup those options are correct, I think option 2 would actually be worthwhile to do

    Could you elaborate on those unintended changes?

    It's been a while so I might not be remembering correctly, but IIRC stripping whitespace messed up the email formatting inside the email and made (yahoo?) emails look especially bad. I think we had this enabled at one point but decided to revert it.

    Maybe we can trim any whitespaces before and after the stripped HTML?

    Yeah this could help a bit, though it looks like in the linked issue the spacing is bad between text and before/after the text too and so it would still look bad

  8. MariaHCD commented on Mar 21, 2022

    @MariaHCD
    Contributor

    Great, thanks, @thienlnam! So moving forward, sounds like the best option would be to investigate usage of another library and this is something that can be handled internally as it is a backend change.

  9. added
    Internal
    on Mar 21, 2022
  10. 36 remaining items

  11. aldo-expensify commented on Jun 4, 2022

    @aldo-expensify
    Contributor

    I investigate this a bit more today and I know better now when it happens, but I haven't been able to come up with a solution. I have a clearer way to reproduce it here: #9195 (comment)

  12. aldo-expensify commented on Jun 8, 2022

    @aldo-expensify
    Contributor

    From what I can see, we have the following cases:

    With white-space: pre Without `white-space: pre` Data
    1 "0 spaces<br /> 1 spaces<br /> 2 spaces<br /> 3 spaces<br /> 4 spaces"
    2 "0 spaces<br /> 1 spaces<br /> 2 spaces<br /> 3 spaces<br /> 4 spaces<br /> <pre>Test</pre>"
    3 " <div class=\"WordSection1\"> <p class=\"MsoNormal\">Hi SomeName, </p><p></p> <p class=\"MsoNormal\"></p><p> </p> <p class=\"MsoNormal\">Will tomorrow at 34 est. work?</p><p></p> <p class=\"MsoNormal\"></p><p> </p> <p class=\"MsoNormal\">Thanks, Test</p><p></p> <p class=\"MsoNormal\"></p><p> </p> </div>xxxxxx xxxxxxxx xx xxx: xxxx x-xxxx xxx xxxxxxxxxx xx xxxxxxxxxxxxx xx xxxxxxxxxxxx xxxxx x.x. xxx, xx xxx xxxxxxx xxxxxxx xx xx xxxxxxxxx xx xxxxxxx x xxx..."
    1. This case is NOT rendered as HTML because of this exception in handling it, so it works in both cases.
    2. and 3. There are other html tags than <br />, so we render these cases using the react-native-render-html library.

    I think it makes sense to add the white-space: pre when we are rendering html messages typed by the user in our App because that makes them render as close as possible to what the user initially typed (preserving spacing). The problem appears when the message came from an email. The email client has a different way of rendering the HTML of the message, they use white-space: normal and &nbsp; to preserve spacing.

    We could try one of the following fixes:

    1. Flag the messages that came from the email intake, don't force white-space: pre for the flagged messages
    2. Check if the message contains a &nbsp;, if it does, don't force white-space: pre
    3. Replace &nbsp; by normal space and keep forcing white-space: pre. This didn't work: Remove whitespace: pre because of extra empty lines bug #9195 (comment)
    4. Do heavier processing of the email in the backend to avoid the amount of weird structured html in them, but that sounds like an endless amount of work.
  13. aldo-expensify commented on Jun 8, 2022

    @aldo-expensify
    Contributor

    Just mentioning that if you edit the message that came from the email reply, it "breaks" like this:

    image

    The result is the same with and without white-space:pre

  14. aldo-expensify commented on Jun 20, 2022

    @aldo-expensify
    Contributor

    I did some more testing today and found out that outlook likes to add a bunch of \n in the email's html. The \n with whitespace: pre makes a lot of empty lines appear.

    The proposed solution of avoid using whitespace: pre for message comings from emails handles well this case, so I'm sticking with that.

    I updated the PR's descriptions and made them ready for review.

  15. added
    Reviewing
    and removed on Jun 20, 2022
  16. melvin-bot commented on Jul 14, 2022

    @melvin-bot

    This issue has not been updated in over 15 days. @aldo-expensify eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

EngineeringImprovementInternalMonthlyReviewing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions