Skip to content

Commit

Permalink
Merge pull request #45352 from Expensify/rodrigo-fix-reportmention-ro…
Browse files Browse the repository at this point in the history
…om-description

Adds support for mentions in room description
  • Loading branch information
Gonals authored Jul 31, 2024
2 parents d0c44aa + 8118954 commit f6861e4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/libs/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Onyx.connect({
return;
}

accountIDToNameMap[personalDetails.accountID] = personalDetails.login ?? String(personalDetails.accountID);
accountIDToNameMap[personalDetails.accountID] = personalDetails.login ?? personalDetails.displayName ?? String(personalDetails.accountID);
});
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ function getReportActionMessageFragments(action: ReportAction): Message[] {
}

if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION)) {
const message = `${Localize.translateLocal('roomChangeLog.updateRoomDescription')} ${getOriginalMessage(action)?.description}`;
const message = getUpdateRoomDescriptionMessage(action);
return [{text: message, html: `<muted-text>${message}</muted-text>`, type: 'COMMENT'}];
}

Expand Down
8 changes: 8 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ type OutstandingChildRequest = {
type ParsingDetails = {
shouldEscapeText?: boolean;
reportID?: string;
policyID?: string;
};

let currentUserEmail: string | undefined;
Expand Down Expand Up @@ -3763,6 +3764,13 @@ function getParsedComment(text: string, parsingDetails?: ParsingDetails): string
isGroupPolicyReport = isReportInGroupPolicy(currentReport);
}

if (parsingDetails?.policyID) {
const policyType = getPolicy(parsingDetails?.policyID)?.type;
if (policyType) {
isGroupPolicyReport = isGroupPolicy(policyType);
}
}

const textWithMention = completeShortMention(text);

return text.length <= CONST.MAX_MARKUP_LENGTH
Expand Down
8 changes: 0 additions & 8 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -648,14 +648,6 @@ function ReportActionItem({
children = <ReportActionItemBasicMessage message={translate('iou.unheldExpense')} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MERGED_WITH_CASH_TRANSACTION) {
children = <ReportActionItemBasicMessage message={translate('systemMessage.mergedWithCashTransaction')} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION) {
children = (
<ReportActionItemMessage
action={action}
reportID={report.reportID}
displayAsGroup={false}
/>
);
} else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) {
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getDismissedViolationMessageText(ReportActionsUtils.getOriginalMessage(action))} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAG) {
Expand Down
6 changes: 3 additions & 3 deletions src/pages/workspace/WorkspaceNewRoomPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function WorkspaceNewRoomPage({policies, reports, formState, session, activePoli
*/
const submit = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.NEW_ROOM_FORM>) => {
const participants = [session?.accountID ?? -1];
const parsedDescription = ReportUtils.getParsedComment(values.reportDescription ?? '');
const parsedDescription = ReportUtils.getParsedComment(values.reportDescription ?? '', {policyID});
const policyReport = ReportUtils.buildOptimisticChatReport(
participants,
values.roomName,
Expand Down Expand Up @@ -183,7 +183,7 @@ function WorkspaceNewRoomPage({policies, reports, formState, session, activePoli
ErrorUtils.addErrorMessage(errors, 'roomName', translate('common.error.characterLimitExceedCounter', {length: values.roomName.length, limit: CONST.TITLE_CHARACTER_LIMIT}));
}

const descriptionLength = ReportUtils.getCommentLength(values.reportDescription);
const descriptionLength = ReportUtils.getCommentLength(values.reportDescription, {policyID});
if (descriptionLength > CONST.REPORT_DESCRIPTION.MAX_LENGTH) {
ErrorUtils.addErrorMessage(
errors,
Expand All @@ -198,7 +198,7 @@ function WorkspaceNewRoomPage({policies, reports, formState, session, activePoli

return errors;
},
[reports, translate],
[reports, policyID, translate],
);

const writeCapabilityOptions = useMemo(
Expand Down

0 comments on commit f6861e4

Please sign in to comment.