From 5f1ca3438990798c9444475df95a0ca864014cd6 Mon Sep 17 00:00:00 2001
From: Huu Le <20178761+huult@users.noreply.github.com>
Date: Fri, 28 Feb 2025 15:40:43 +0700
Subject: [PATCH 1/2] update markdown rendering

---
 src/libs/actions/Policy/Policy.ts                | 3 +++
 src/pages/workspace/rules/CustomRulesSection.tsx | 7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts
index d20e9cd04a08..4aaa60aa4e9c 100644
--- a/src/libs/actions/Policy/Policy.ts
+++ b/src/libs/actions/Policy/Policy.ts
@@ -3853,6 +3853,7 @@ function setPolicyMaxExpenseAge(policyID: string, maxExpenseAge: string) {
                     pendingFields: {
                         maxExpenseAge: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
                     },
+                    isLoading: true,
                 },
             },
         ],
@@ -3864,6 +3865,7 @@ function setPolicyMaxExpenseAge(policyID: string, maxExpenseAge: string) {
                     pendingFields: {
                         maxExpenseAge: null,
                     },
+                    isLoading: false,
                 },
             },
         ],
@@ -3875,6 +3877,7 @@ function setPolicyMaxExpenseAge(policyID: string, maxExpenseAge: string) {
                     maxExpenseAge: originalMaxExpenseAge,
                     pendingFields: {maxExpenseAge: null},
                     errorFields: {maxExpenseAge: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage')},
+                    isLoading: false,
                 },
             },
         ],
diff --git a/src/pages/workspace/rules/CustomRulesSection.tsx b/src/pages/workspace/rules/CustomRulesSection.tsx
index 0a55f63e7437..fc3b5e0c3a57 100644
--- a/src/pages/workspace/rules/CustomRulesSection.tsx
+++ b/src/pages/workspace/rules/CustomRulesSection.tsx
@@ -17,7 +17,12 @@ function CustomRulesSection({policyID}: CustomRulesSectionProps) {
     const {translate} = useLocalize();
     const styles = useThemeStyles();
     const policy = usePolicy(policyID);
-    const parsedRules = useMemo(() => getParsedComment(policy?.customRules ?? ''), [policy]);
+    const parsedRules = useMemo(() => {
+        const customRules = policy?.customRules ?? '';
+        const options = policy?.isLoading ? {shouldEscapeText: false} : undefined;
+
+        return getParsedComment(customRules, options);
+    }, [policy]);
     const rulesDescription = typeof parsedRules === 'string' ? parsedRules : '';
 
     return (

From b92e1be1ec3aa9870300bb160b7bb4ec314cab11 Mon Sep 17 00:00:00 2001
From: Huu Le <20178761+huult@users.noreply.github.com>
Date: Fri, 28 Feb 2025 15:58:56 +0700
Subject: [PATCH 2/2] add isLoading for updateCustomRules

---
 src/libs/actions/Policy/Policy.ts | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts
index 4aaa60aa4e9c..5f965b5e71b4 100644
--- a/src/libs/actions/Policy/Policy.ts
+++ b/src/libs/actions/Policy/Policy.ts
@@ -3853,7 +3853,6 @@ function setPolicyMaxExpenseAge(policyID: string, maxExpenseAge: string) {
                     pendingFields: {
                         maxExpenseAge: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
                     },
-                    isLoading: true,
                 },
             },
         ],
@@ -3865,7 +3864,6 @@ function setPolicyMaxExpenseAge(policyID: string, maxExpenseAge: string) {
                     pendingFields: {
                         maxExpenseAge: null,
                     },
-                    isLoading: false,
                 },
             },
         ],
@@ -3877,7 +3875,6 @@ function setPolicyMaxExpenseAge(policyID: string, maxExpenseAge: string) {
                     maxExpenseAge: originalMaxExpenseAge,
                     pendingFields: {maxExpenseAge: null},
                     errorFields: {maxExpenseAge: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage')},
-                    isLoading: false,
                 },
             },
         ],
@@ -3911,6 +3908,7 @@ function updateCustomRules(policyID: string, customRules: string) {
                 key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
                 value: {
                     customRules: parsedCustomRules,
+                    isLoading: true,
                 },
             },
         ],
@@ -3923,6 +3921,7 @@ function updateCustomRules(policyID: string, customRules: string) {
                         // TODO
                         // maxExpenseAge: null,
                     },
+                    isLoading: false,
                 },
             },
         ],
@@ -3932,6 +3931,7 @@ function updateCustomRules(policyID: string, customRules: string) {
                 key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
                 value: {
                     customRules: originalCustomRules,
+                    isLoading: false,
                     // TODO
                     // pendingFields: {maxExpenseAge: null},
                     // errorFields: {maxExpenseAge: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage')},
