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

fix: Subject of the room briefly displayed as json string #50838

Merged
merged 7 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4239,12 +4239,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 @@ -8418,7 +8423,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 @@ -573,7 +573,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 @@ -802,7 +802,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
Loading