Skip to content

Commit 2e84417

Browse files
authored
Merge pull request Expensify#85015 from Expensify/revert-84452-marco/fix-followup-formatting-bugs
2 parents 6e53bf9 + 492b590 commit 2e84417

3 files changed

Lines changed: 7 additions & 21 deletions

File tree

src/libs/ReportActionFollowupUtils/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import render from 'dom-serializer';
21
import {DomUtils, parseDocument} from 'htmlparser2';
32
import {getReportActionMessage, isActionOfType} from '@libs/ReportActionsUtils';
43
import CONST from '@src/CONST';
@@ -54,7 +53,7 @@ function parseFollowupsFromHtml(html: string): Followup[] | null {
5453
const followupTextElement = DomUtils.getElementsByTagName('followup-text', followupEl, true).at(0);
5554
const followupResponseElement = DomUtils.getElementsByTagName('followup-response', followupEl, true).at(0);
5655
const text = followupTextElement ? DomUtils.textContent(followupTextElement) : '';
57-
const response = followupResponseElement ? render(followupResponseElement.children) : undefined;
56+
const response = followupResponseElement ? DomUtils.textContent(followupResponseElement) : undefined;
5857
return {text, response};
5958
});
6059
}

src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import Navigation from '@libs/Navigation/Navigation';
2323
import Parser from '@libs/Parser';
2424
import {getCleanedTagName, isPolicyAdmin} from '@libs/PolicyUtils';
2525
import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager';
26-
import stripFollowupListFromHtml from '@libs/ReportActionFollowupUtils/stripFollowupListFromHtml';
2726
import {
2827
getActionableCardFraudAlertMessage,
2928
getActionableMentionWhisperMessage,
@@ -1074,9 +1073,8 @@ const ContextMenuActions: ContextMenuAction[] = [
10741073
);
10751074
setClipboardMessage(displayMessage);
10761075
} else if (content) {
1077-
const contentWithoutFollowups = stripFollowupListFromHtml(content) ?? content;
10781076
setClipboardMessage(
1079-
contentWithoutFollowups.replaceAll(/(<mention-user>)(.*?)(<\/mention-user>)/gi, (match, openTag: string, innerContent: string, closeTag: string): string => {
1077+
content.replaceAll(/(<mention-user>)(.*?)(<\/mention-user>)/gi, (match, openTag: string, innerContent: string, closeTag: string): string => {
10801078
const modifiedContent = Str.removeSMSDomain(innerContent) || '';
10811079
return openTag + modifiedContent + closeTag || '';
10821080
}),

tests/unit/ReportActionsFollowupUtilsTest.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,14 @@ describe('ReportActionsFollowupUtils', () => {
6262
expect(parseFollowupsFromHtml(html)).toEqual([]);
6363
});
6464

65-
it('should parse followup with pre-generated response preserving HTML', () => {
65+
it('should parse followup with pre-generated response', () => {
6666
const html = `<followup-list>
6767
<followup>
6868
<followup-text>How do I set up QuickBooks?</followup-text>
69-
<followup-response>To set up QuickBooks, go to <strong>Settings</strong> &gt; Integrations.</followup-response>
69+
<followup-response>To set up QuickBooks, go to Settings > Integrations...</followup-response>
7070
</followup>
7171
</followup-list>`;
72-
expect(parseFollowupsFromHtml(html)).toEqual([{text: 'How do I set up QuickBooks?', response: 'To set up QuickBooks, go to <strong>Settings</strong> > Integrations.'}]);
73-
});
74-
75-
it('should preserve bullet lists in pre-generated responses', () => {
76-
const html = `<followup-list>
77-
<followup>
78-
<followup-text>What are the steps?</followup-text>
79-
<followup-response><ul><li>Step one</li><li>Step two</li></ul></followup-response>
80-
</followup>
81-
</followup-list>`;
82-
const result = parseFollowupsFromHtml(html);
83-
expect(result).toEqual([{text: 'What are the steps?', response: '<ul><li>Step one</li><li>Step two</li></ul>'}]);
72+
expect(parseFollowupsFromHtml(html)).toEqual([{text: 'How do I set up QuickBooks?', response: 'To set up QuickBooks, go to Settings > Integrations...'}]);
8473
});
8574

8675
it('should parse multiple followups with mixed response availability', () => {
@@ -90,12 +79,12 @@ describe('ReportActionsFollowupUtils', () => {
9079
</followup>
9180
<followup>
9281
<followup-text>Question with response</followup-text>
93-
<followup-response>Here is the <strong>cached</strong> response</followup-response>
82+
<followup-response>Here is the cached response</followup-response>
9483
</followup>
9584
</followup-list>`;
9685
expect(parseFollowupsFromHtml(html)).toEqual([
9786
{text: 'Question without response', response: undefined},
98-
{text: 'Question with response', response: 'Here is the <strong>cached</strong> response'},
87+
{text: 'Question with response', response: 'Here is the cached response'},
9988
]);
10089
});
10190

0 commit comments

Comments
 (0)