Skip to content

Commit

Permalink
Merge pull request Expensify#50838 from truph01/fix/49355
Browse files Browse the repository at this point in the history
fix: Subject of the room briefly displayed as json string
  • Loading branch information
techievivek authored Oct 30, 2024
2 parents fe779d9 + 04b9838 commit 6cd5c64
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
13 changes: 9 additions & 4 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4258,12 +4258,17 @@ function getUploadingAttachmentHtml(file?: FileObject): string {
return `<a href="${file.uri}" ${dataAttributes}>${file.name}</a>`;
}

function getReportDescriptionText(report: OnyxEntry<Report>): string {
function getReportDescription(report: OnyxEntry<Report>): string {
if (!report?.description) {
return '';
}

return Parser.htmlToText(report?.description);
try {
const reportDescription = report?.description;
const objectDescription = JSON.parse(reportDescription) as {html: string};
return objectDescription.html ?? '';
} catch (error) {
return report?.description ?? '';
}
}

function getPolicyDescriptionText(policy: OnyxEntry<Policy>): string {
Expand Down Expand Up @@ -8447,7 +8452,7 @@ export {
getReimbursementDeQueuedActionMessage,
getReimbursementQueuedActionMessage,
getReportActionActorAccountID,
getReportDescriptionText,
getReportDescription,
getReportFieldKey,
getReportIDFromLink,
getReportName,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ function getRoomWelcomeMessage(report: OnyxEntry<Report>): WelcomeMessage {
const workspaceName = ReportUtils.getPolicyName(report);

if (report?.description) {
welcomeMessage.messageHtml = report.description;
welcomeMessage.messageHtml = ReportUtils.getReportDescription(report);
welcomeMessage.messageText = Parser.htmlToText(welcomeMessage.messageHtml);
return welcomeMessage;
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ function ReportDetailsPage({policies, report, route}: ReportDetailsPageProps) {
<MenuItemWithTopDescription
shouldShowRightIcon
interactive
title={report.description}
title={ReportUtils.getReportDescription(report)}
shouldRenderAsHTML
shouldTruncateTitle
characterLimit={100}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RoomDescriptionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function RoomDescriptionPage({report, policies}: RoomDescriptionPageProps) {
const route = useRoute<RouteProp<ReportDescriptionNavigatorParamList, typeof SCREENS.REPORT_DESCRIPTION_ROOT>>();
const backTo = route.params.backTo;
const styles = useThemeStyles();
const [description, setDescription] = useState(() => Parser.htmlToMarkdown(report?.description ?? ''));
const [description, setDescription] = useState(() => Parser.htmlToMarkdown(ReportUtils.getReportDescription(report)));
const reportDescriptionInputRef = useRef<BaseTextInputRef | null>(null);
const focusTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const {translate} = useLocalize();
Expand Down
3 changes: 2 additions & 1 deletion src/pages/home/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import isReportOpenInRHP from '@libs/Navigation/isReportOpenInRHP';
import Navigation, {navigationRef} from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import Parser from '@libs/Parser';
import * as ReportUtils from '@libs/ReportUtils';
import FreeTrialBadge from '@pages/settings/Subscription/FreeTrialBadge';
import * as Report from '@userActions/Report';
Expand Down Expand Up @@ -91,7 +92,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto
const title = ReportUtils.getReportName(reportHeaderData, policy, parentReportAction, personalDetails, invoiceReceiverPolicy);
const subtitle = ReportUtils.getChatRoomSubtitle(reportHeaderData);
const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(reportHeaderData);
const reportDescription = ReportUtils.getReportDescriptionText(report);
const reportDescription = Parser.htmlToText(ReportUtils.getReportDescription(report));
const policyName = ReportUtils.getPolicyName(report, true);
const policyDescription = ReportUtils.getPolicyDescriptionText(policy);
const isPersonalExpenseChat = isPolicyExpenseChat && ReportUtils.isCurrentUserSubmitter(report?.reportID ?? '');
Expand Down

0 comments on commit 6cd5c64

Please sign in to comment.