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-02] [$250] mWeb - Room - System message for room description with markdown is shown as html code #44448

Closed
1 of 6 tasks
lanitochka17 opened this issue Jun 26, 2024 · 25 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 External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Jun 26, 2024

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


Version Number: 9.0.2
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4672130
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/home
  2. Tap on a room chat
  3. Tap header-- room description
  4. Enter 🦢💫😁🤡
  5. Save the description
  6. In room conversation page, note the system message of room description saved

Expected Result:

System message for room description with markdown must not be shown as html code

Actual Result:

System message for room description with markdown is shown as html code

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6524679_1719360869830.Screenrecorder-2024-06-26-05-37-06-269_compress_1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01c48ce1e75fd4d291
  • Upwork Job ID: 1814416039583443889
  • Last Price Increase: 2024-07-19
  • Automatic offers:
    • allgandalf | Contributor | 103199145
Issue OwnerCurrent Issue Owner: @miljakljajic
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 26, 2024
Copy link

melvin-bot bot commented Jun 26, 2024

Triggered auto assignment to @miljakljajic (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@lanitochka17
Copy link
Author

@miljakljajic FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@lanitochka17
Copy link
Author

We think that this bug might be related to #vip-vsp

@bernhardoj
Copy link
Contributor

Caused by #44300

@melvin-bot melvin-bot bot added the Overdue label Jun 28, 2024
Copy link

melvin-bot bot commented Jul 1, 2024

@miljakljajic Huh... This is 4 days overdue. Who can take care of this?

@miljakljajic
Copy link
Contributor

@roryabraham @yuwenmemon is this a regression from #44300?

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jul 3, 2024
Copy link

melvin-bot bot commented Jul 8, 2024

@miljakljajic Eep! 4 days overdue now. Issues have feelings too...

@lanitochka17
Copy link
Author

Issue is still reproducible on the latest build 9.0.9-1

Screenrecorder-2024-07-18-22-29-22-847.mp4

@lanitochka17 lanitochka17 reopened this Jul 18, 2024
@bernhardoj
Copy link
Contributor

Because it's not fixed yet, I posted my proposal.

Proposal

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

The system message of the room description update is shown with an HTML tag.

What is the root cause of that problem?

If the action is an update room description, we use ReportActionItemBasicMessage.

} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION) {
const message = `${translate('roomChangeLog.updateRoomDescription')} ${(originalMessage as OriginalMessageChangeLog)?.description}`;
children = <ReportActionItemBasicMessage message={message} />;
} else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) {

ReportActionItemBasicMessage only renders it as plain text. This happens after #44300 which will also make the message translatable. Previously, we didn't check for the update room description action and let it be rendered by ReportActionItemMessage which uses TextCommentFragment that will render the HTML correctly. The fragment is constructed from the action message as shown below.

const actionMessage = action.previousMessage ?? action.message;
let fragments: Message[] = [];
if (Array.isArray(actionMessage)) {
fragments = actionMessage.filter((item): item is Message => !!item);
} else {
fragments = actionMessage ? [actionMessage] : [];
}

if (!shouldRenderAsText(html, text ?? '') && !(containsOnlyEmojis && styleAsDeleted)) {
const editedTag = fragment?.isEdited ? `<edited ${styleAsDeleted ? 'deleted' : ''} ${containsOnlyEmojis ? 'islarge' : ''}></edited>` : '';
const htmlWithDeletedTag = styleAsDeleted ? `<del>${html}</del>` : html;
const htmlContent = containsOnlyEmojis ? Str.replaceAll(htmlWithDeletedTag, '<emoji>', '<emoji islarge>') : htmlWithDeletedTag;
let htmlWithTag = editedTag ? `${htmlContent}${editedTag}` : htmlContent;
if (styleAsMuted) {
htmlWithTag = `<muted-text>${htmlWithTag}<muted-text>`;
}
return (
<RenderCommentHTML
source={source}
html={htmlWithTag}
/>
);
}
const message = isEmpty(iouMessage) ? text : iouMessage;
return (
<Text style={[containsOnlyEmojis && styles.onlyEmojisText, styles.ltr, style]}>
<ZeroWidthView
text={text}
displayAsGroup={displayAsGroup}

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

We need to use ReportActionItemMessage back by removing this code

} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION) {
const message = `${translate('roomChangeLog.updateRoomDescription')} ${(originalMessage as OriginalMessageChangeLog)?.description}`;
children = <ReportActionItemBasicMessage message={message} />;

and to keep make it translatable, in ReportActionItemMessage, we need to construct a custom fragments array for the update room description action.

let fragments: Message[] = [];
if (action.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION) {
    const message = `${translate('roomChangeLog.updateRoomDescription')} ${ReportActionsUtils.getOriginalMessage(action)?.description}`;
    fragments = [{text: message, html: `<muted-text>${message}</muted-text>`, type: 'COMMENT'}];
} else {
    if (Array.isArray(actionMessage)) {
        fragments = actionMessage.filter((item): item is Message => !!item);
    } else {
        fragments = actionMessage ? [actionMessage] : [];
    }
}

Last, we need to use Parser.htmlToText for the description here

result.alternateText = `${lastActorDisplayName} ${Localize.translate(preferredLocale, 'roomChangeLog.updateRoomDescription')} ${lastActionOriginalMessage?.description}`.trim();

@roryabraham roryabraham self-assigned this Jul 19, 2024
@roryabraham roryabraham added the External Added to denote the issue can be worked on by a contributor label Jul 19, 2024
@melvin-bot melvin-bot bot changed the title mWeb - Room - System message for room description with markdown is shown as html code [$250] mWeb - Room - System message for room description with markdown is shown as html code Jul 19, 2024
Copy link

melvin-bot bot commented Jul 19, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01c48ce1e75fd4d291

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

melvin-bot bot commented Jul 19, 2024

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

@roryabraham roryabraham assigned bernhardoj and unassigned suneox Jul 19, 2024
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 19, 2024
@melvin-bot melvin-bot bot added the Reviewing Has a PR in review label Jul 20, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Jul 20, 2024
@bernhardoj
Copy link
Contributor

PR is ready

@allgandalf
Copy link
Contributor

I was assigned to the linked PR as C+, does that require a C+ review @roryabraham @miljakljajic ?

@roryabraham
Copy link
Contributor

Didn't mean to unassign the original C+, but now that you're assigned to review the PR you can keep it. Thanks in advance for your review @allgandalf

Copy link

melvin-bot bot commented Jul 20, 2024

📣 @allgandalf 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@allgandalf
Copy link
Contributor

Thanks, I will complete the checklist over the weekend 👍

@roryabraham
Copy link
Contributor

roryabraham commented Jul 23, 2024

PR is merged

@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 26, 2024
@melvin-bot melvin-bot bot changed the title [$250] mWeb - Room - System message for room description with markdown is shown as html code [HOLD for payment 2024-08-02] [$250] mWeb - Room - System message for room description with markdown is shown as html code Jul 26, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 26, 2024
Copy link

melvin-bot bot commented Jul 26, 2024

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

Copy link

melvin-bot bot commented Jul 26, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.12-0 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-02. 🎊

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

Copy link

melvin-bot bot commented Jul 26, 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:

  • [@allgandalf] The PR that introduced the bug has been identified. Link to the PR:
  • [@allgandalf] 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:
  • [@allgandalf] 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:
  • [@allgandalf] Determine if we should create a regression test for this bug.
  • [@allgandalf] 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.
  • [@miljakljajic] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@allgandalf
Copy link
Contributor

Regression Test Proposal

  • Open a room or create a new one
  • Update the room description to contain an emoji/markdown
  • Verify the update room description system message is rendered as markdown
  • Go back to LHN
  • Verify the room last message shows the message as plain text

Do we agree 👍 or 👎

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

@bernhardoj is owed 250 USD for their work reviewing this issue

@melvin-bot melvin-bot bot removed the Overdue label Aug 5, 2024
@miljakljajic
Copy link
Contributor

@allgandalf paid you in upwork!

@bernhardoj
Copy link
Contributor

Requested in ND.

@JmillsExpensify
Copy link

$250 approved for @bernhardoj

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 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

7 participants