File tree Expand file tree Collapse file tree
src/components/MoneyRequestConfirmationList/sections Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import useOnyx from '@hooks/useOnyx';
1010import useThemeStyles from '@hooks/useThemeStyles' ;
1111import { setMoneyRequestDescription } from '@libs/actions/IOU' ;
1212import Navigation from '@libs/Navigation/Navigation' ;
13+ import Parser from '@libs/Parser' ;
1314import { getDescription , hasReceipt } from '@libs/TransactionUtils' ;
1415import variables from '@styles/variables' ;
1516import { setDraftSplitTransaction } from '@userActions/IOU/Split' ;
@@ -53,7 +54,9 @@ function DescriptionField({
5354
5455 const [ splitDraftTransaction ] = useOnyx ( `${ ONYXKEYS . COLLECTION . SPLIT_TRANSACTION_DRAFT } ${ transactionID } ` ) ;
5556
56- const iouComment = getDescription ( transaction ) ;
57+ // `getDescription` returns raw `transaction.comment.comment`, which can be HTML for saved transactions.
58+ // We normalize to markdown so both the read-only and editable inputs receive a consistent format.
59+ const iouComment = Parser . htmlToMarkdown ( getDescription ( transaction ) ) ;
5760
5861 const contextMenuStateValue = {
5962 anchor : null ,
Original file line number Diff line number Diff line change @@ -24,4 +24,28 @@ describe('Parser', () => {
2424 expect ( Parser . isHTML ( '<>' ) ) . toBe ( false ) ;
2525 } ) ;
2626 } ) ;
27+
28+ describe ( 'htmlToMarkdown' , ( ) => {
29+ // These cases pin the contract relied on by DescriptionField.tsx, where the description of a saved
30+ // transaction is stored as HTML (because `getParsedComment()` runs ExpensiMark at save time) and must
31+ // be normalized back to markdown before being handed to the `shouldParseTitle` MenuItem and the
32+ // `type="markdown"` TextInput. Without this normalization, the Split details page renders raw `<a>`
33+ // tags as visible text — see https://github.com/Expensify/App/issues/87519.
34+ test ( 'converts an autolinked URL anchor back to a markdown link' , ( ) => {
35+ expect ( Parser . htmlToMarkdown ( '<a href="https://google.com" target="_blank" rel="noreferrer noopener">google.com</a>' ) ) . toBe ( '[google.com](https://google.com)' ) ;
36+ } ) ;
37+
38+ test ( 'converts ExpensiMark-emitted bold tags back to markdown asterisks' , ( ) => {
39+ expect ( Parser . htmlToMarkdown ( '<strong>hello</strong> world' ) ) . toBe ( '*hello* world' ) ;
40+ } ) ;
41+
42+ test ( 'is a no-op for plain text descriptions used by draft transactions' , ( ) => {
43+ expect ( Parser . htmlToMarkdown ( 'lunch' ) ) . toBe ( 'lunch' ) ;
44+ expect ( Parser . htmlToMarkdown ( 'google.com' ) ) . toBe ( 'google.com' ) ;
45+ } ) ;
46+
47+ test ( 'returns an empty string for an empty input' , ( ) => {
48+ expect ( Parser . htmlToMarkdown ( '' ) ) . toBe ( '' ) ;
49+ } ) ;
50+ } ) ;
2751} ) ;
You can’t perform that action at this time.
0 commit comments