Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD for payment 2024-08-07] [$1000] Extra space around text in header of reply in thread if main message has 3 backtick code block #22832

Closed
4 of 6 tasks
kbecciv opened this issue Jul 13, 2023 · 137 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Not a priority

Comments

@kbecciv
Copy link

kbecciv commented Jul 13, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Open the app
  2. Open any report
  3. Send message with 3 backtick code block in it eg: hi hello test
  4. Hover and click on reply in thread
  5. Observe the header text, it will have extra spaces around text which was 3 backtick code block

Expected Result:

Format of text should not affect reply in thread header text formatting

Actual Result:

3 backtick code blocks in text adds extra space around the text in reply in thread header

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.39-10
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: Any additional supporting documentation

2023-07-13.23-21-57.mp4
Recording.3603.mp4

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~010cf4dbd8dbc4da67
  • Upwork Job ID: 1684257620704722944
  • Last Price Increase: 2023-08-09
  • Automatic offers:
    • tienifr | Contributor | 26112867
    • dhanashree-sawant | Reporter | 26112869
Issue OwnerCurrent Issue Owner: @alexpensify
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 13, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 13, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 13, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@eh2077
Copy link
Contributor

eh2077 commented Jul 14, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Extra space around text in header of reply in thread if main message has 3 backtick code block.

What is the root cause of that problem?

The root cause of this issue is that we format header of report thread by replacing line break of message[0].text with a space, see

const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').replace(/(\r\n|\n|\r)/gm, ' ');

So, there's will be an extra space added for message[0].text, like hi \nhello.

What changes do you think we should make in order to solve the problem?

To fix this issue, we can convert html lodashGet(parentReportAction, ['message', 0, 'html'], '') to markdown text and then get the first line of the markdown text.

To achieve it, we can change this line

const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').replace(/(\r\n|\n|\r)/gm, ' ');

to

const parser = new ExpensiMark();
const parentReportActionMessage = parser.htmlToMarkdown(lodashGet(parentReportAction, ['message', 0, 'html'], '')).trim().replace(CONST.REGEX.AFTER_FIRST_LINE_BREAK, '');

What alternative solutions did you explore? (Optional)

If we don't want to show the Markdown in the title, then we can just get the first line of

lodashGet(parentReportAction, ['message', 0, 'text'], '')

by changing this line

const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').replace(/(\r\n|\n|\r)/gm, ' ');

to

const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').trim().replace(CONST.REGEX.AFTER_FIRST_LINE_BREAK, '');

@melvin-bot melvin-bot bot added the Overdue label Jul 17, 2023
@flaviadefaria
Copy link
Contributor

I'm discussing it in Slack here to confirm what would be the expected result.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jul 18, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 21, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 25, 2023

@flaviadefaria Still overdue 6 days?! Let's take care of this!

@flaviadefaria
Copy link
Contributor

flaviadefaria commented Jul 26, 2023

After discussing in Slack we agreed that the intended outcome should be:

  • Only the first line of the message should display on the thread title
  • Markdown, if in a thread title, should display as markdown

@melvin-bot melvin-bot bot removed the Overdue label Jul 26, 2023
@flaviadefaria flaviadefaria added the External Added to denote the issue can be worked on by a contributor label Jul 26, 2023
@melvin-bot melvin-bot bot changed the title Extra space around text in header of reply in thread if main message has 3 backtick code block [$1000] Extra space around text in header of reply in thread if main message has 3 backtick code block Jul 26, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 26, 2023

Job added to Upwork: https://www.upwork.com/jobs/~010cf4dbd8dbc4da67

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 26, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 26, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 26, 2023

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

@munsuyog
Copy link

Proposal

Please re-state the problem that we are trying to solve in this issue.

The problem we aim to solve in this issue is related to the formatting of the reply in thread header text. When a message with a 3 backtick code block is sent, it adds extra spaces around the text in the reply in thread header.

What is the root cause of that problem?

The root cause of the problem lies in the regular expression used to replace line breaks in the "parentReportActionMessage" variable. The current regular expression (/(\r\n|\n|\r)/gm, ' ') is replacing line breaks with spaces, which may lead to unintended formatting issues in the processed text.

What changes do you think we should make in order to solve the problem?

To address the problem, we propose the following changes to the code in the file "App/src/libs/ReportUtils.js":
const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').trim();
By using the trim() method, we can remove any leading or trailing whitespace, including line breaks, without replacing them with spaces. This ensures that the formatting of the message text remains intact and consistent.

What alternative solutions did you explore? (Optional)

While the proposed solution is straightforward and effective, we could also consider an alternative approach:
const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').replace(/[\r\n]+/g, ' ');

In this alternative solution, we use a regular expression (/[\r\n]+/g) to directly replace consecutive line breaks with a single space. This approach achieves the same result as the proposed solution but retains the use of regular expressions.

@tienifr
Copy link
Contributor

tienifr commented Jul 27, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Thread header is not displayed properly.

We have the expected outcome here #22832 (comment).

Only the first line of the message should display on the thread title
Markdown, if in a thread title, should display as markdown

What is the root cause of that problem?

Our thread title logic here is not following the above expected outcome. Currently it's only replacing the line break.

What changes do you think we should make in order to solve the problem?

  1. Create a dedicated method to get the thread name HTML that accepts a parentReportAction
  2. In the method, extract the first line of the report action message HTML and return. We'll extract it by finding all the content from the first line-breaking opening tags (br, h1, pre, ...) till end, and replace it with proper closing tags.

For example, if the html is hello <br /><h1>there</h1>, it will replace <br /><h1>there</h1> with ''
If the html is <pre> hello<br />there</pre>, it will replace <br />there</pre> with </pre>

  1. Modify the DisplayNames component to accept a fullTitleHtml, if it exists, will render it in a <RenderHTML in here https://github.com/Expensify/App/blob/f8bb2b116439ab5210c80eb807a1b843ef37307d/src/components/DisplayNames/index.js#L87C1-L87C1 (same change in the .native file as well). Some style fixes might be necessary.
  2. Check if the parent report action message of the thread contains HTML, if yes, pass in fullTitleHtml (from step 2) to here

What alternative solutions did you explore? (Optional)

NA

@Habben101
Copy link

Habben101 commented Jul 27, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Markdown formatting is not being applied to the thread title even when the message contains markdown and only the first line of the message is not being displayed as the thread title.

What is the root cause of that problem?

The root cause of the problem is in the way the 'parentReportActionMessage' is obtained and processed.

const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').replace(/(\r\n|\n|\r)/gm, ' ');

The code uses a regular expression to replace newline characters with spaces, but it does not handle markdown properly.

What changes do you think we should make in order to solve the problem?

As mentioned here the intended outcome should be Only the first line of the message should display on the thread title and the thread title should display as markdown if it is a md. To achive the intended outcome, we could change this to:

const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'html'], '');

And then we can write a dedicated function like RenderHTML that can accept the parentReportActionMessage and Extract first line from the md. To extract the first line, we can add the following lines to DisplayNames component.

const lines = this.props.fullTitle.split('<br />');
const firstLine = lines[0].trim();

And pass it to RenderHTMLHeaderView ,which is similar to RenderHTML, to be rendered.

Result:

scrnli_8_7_2023_4-18-08.AM.mp4

What alternative solutions did you explore? (Optional)

NA

@melvin-bot
Copy link

melvin-bot bot commented Jul 27, 2023

@sobitneupane @flaviadefaria this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@sobitneupane
Copy link
Contributor

@flaviadefaria After going through the above proposals, I am pretty sure most of us are not clear about the expected output.

So, bo be clear on the expected output:

If we have highlighted text as the message, what will be the header.

  1. # highlighted text
  2. highlighted text

If we have following code block as the message, what will be the header.

line1
line2

@munsuyog
Copy link

munsuyog commented Jul 28, 2023

@flaviadefaria After going through the above proposals, I am pretty sure most of us are not clear about the expected output.

So, bo be clear on the expected output:

If we have highlighted text as the message, what will be the header.

  1. # highlighted text
  2. highlighted text

If we have following code block as the message, what will be the header.

line1
line2

If the message contains the following code block:

# highlighted text

The header of the reply in the thread will be:

# highlighted text

Since the code block is surrounded by backticks, it will be treated as inline code and won't be affected by the regular expression replace(/(\r\n|\n|\r)/gm, ' '). The header will retain the exact formatting of the original code block, including the backticks and the '#' symbol.

If the message contains the following text:

# highlighted text

The header of the reply in the thread will be:

highlighted text

The # symbol at the beginning of the line is treated as a Markdown heading. When replying in a thread, the header text displays only the content of the heading without the '#' symbol. Therefore, the header will show the text "highlighted text" without the formatting of a heading.

If the message contains the following code block:

line1
line2

The header of the reply in the thread will be:

line1 line2

The backtick code block is treated as inline code and won't be affected by the regular expression replace(/(\r\n|\n|\r)/gm, ' '). The header will show the content of the code block without the line breaks, resulting in a single line: "line1 line2".

@melvin-bot melvin-bot bot added the Overdue label Jul 31, 2023
@flaviadefaria
Copy link
Contributor

flaviadefaria commented Jul 31, 2023

Hey @sobitneupane happy to clarify so I think we're aiming to fix 2 separate things here:

  1. Only the first line of the message should display on the thread title (regardless of if there's any markdown in the message)
  2. If there's Markdown in a message that is in a thread title it should display as markdown

If we have highlighted text as the message, what will be the header.

Exactly what's below though for number 2 I'd imagine we'd match the font size to the regular thread title size.

  1. # highlighted text
  2. highlighted text

If we have following code block as the message, what will be the header.

The header will be line1 only.

line1

Let me know if this helps or if you still have any questions.

@melvin-bot melvin-bot bot removed the Overdue label Jul 31, 2023
@alexpensify alexpensify added Weekly KSv2 and removed Monthly KSv2 labels Jul 22, 2024
@sobitneupane
Copy link
Contributor

Thanks for the proposal @tienifr.

Proposal from @tienifr looks good.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Jul 23, 2024

Current assignee @robertjchen is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Jul 24, 2024
@sobitneupane
Copy link
Contributor

Waiting for @robertjchen's response on #22832 (comment)

@robertjchen
Copy link
Contributor

makes sense to me- let's try that

@alexpensify
Copy link
Contributor

@robertjchen - thanks, we need you to approve the proposal to carry on with the next steps. Thanks!

@robertjchen
Copy link
Contributor

robertjchen commented Jul 29, 2024

Yep, already approved above! #22832 (comment)

@alexpensify
Copy link
Contributor

Whoops, I missed the automation ran many months ago. Ok, @tienifr keep us posted when the PR is ready for review. Thanks!

@tienifr
Copy link
Contributor

tienifr commented Jul 29, 2024

@alexpensify PR was merged #45734.

@alexpensify
Copy link
Contributor

Thanks! We will wait for it to go through the automation process to production.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jul 31, 2024
@melvin-bot melvin-bot bot changed the title [$1000] Extra space around text in header of reply in thread if main message has 3 backtick code block [HOLD for payment 2024-08-07] [$1000] Extra space around text in header of reply in thread if main message has 3 backtick code block Jul 31, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 31, 2024
Copy link

melvin-bot bot commented Jul 31, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Jul 31, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.14-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-08-07. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jul 31, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@sobitneupane] The PR that introduced the bug has been identified. Link to the PR:
  • [@sobitneupane] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@sobitneupane] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@sobitneupane] Determine if we should create a regression test for this bug.
  • [@sobitneupane] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@alexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Aug 7, 2024
@alexpensify
Copy link
Contributor

I'm working on the payment process and will complete it tomorrow.

@melvin-bot melvin-bot bot removed the Overdue label Aug 7, 2024
@alexpensify
Copy link
Contributor

alexpensify commented Aug 11, 2024

Payouts due: 2024-08-07

Upwork job is here.

@alexpensify
Copy link
Contributor

Closing - I've completed the process in Upwork. @sobitneupane, please submit a request in Chat. Thanks!

@garrettmknight
Copy link
Contributor

$1000 approved for @sobitneupane based on this summary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Not a priority
Projects
No open projects
Archived in project
Development

No branches or pull requests