Skip to content

fix: the system message when someone requests to join a workspace #51843

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

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3886,6 +3886,7 @@ const translations = {
personalMessagePrompt: 'Message',
genericFailureMessage: 'An error occurred while inviting the member to the workspace. Please try again.',
inviteNoMembersError: 'Please select at least one member to invite.',
joinRequest: ({user}: {user: string}) => `${user} requested to join the workspace`,
},
distanceRates: {
oopsNotSoFast: 'Oops! Not so fast...',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3930,6 +3930,7 @@ const translations = {
personalMessagePrompt: 'Mensaje',
inviteNoMembersError: 'Por favor, selecciona al menos un miembro a invitar.',
genericFailureMessage: 'Se ha producido un error al invitar al miembro al espacio de trabajo. Por favor, vuelva a intentarlo.',
joinRequest: ({user}: {user: string}) => `${user} requested to join the workspace`,
},
distanceRates: {
oopsNotSoFast: 'Ups! No tan rápido...',
Expand Down
2 changes: 2 additions & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,8 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
lastMessageTextFromReport = ReportActionUtils.getExportIntegrationLastMessageText(lastReportAction);
} else if (lastReportAction?.actionName && ReportActionUtils.isOldDotReportAction(lastReportAction)) {
lastMessageTextFromReport = ReportActionUtils.getMessageOfOldDotReportAction(lastReportAction, false);
} else if (ReportActionUtils.isActionableJoinRequest(lastReportAction)) {
lastMessageTextFromReport = ReportUtils.getJoinRequestMessage(lastReportAction);
}

return lastMessageTextFromReport || (report?.lastMessageText ?? '');
Expand Down
9 changes: 9 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3880,6 +3880,10 @@ function getReportName(
return getIOUUnapprovedMessage(parentReportAction);
}

if (ReportActionsUtils.isActionableJoinRequest(parentReportAction)) {
return getJoinRequestMessage(parentReportAction);
}

if (isChatThread(report)) {
if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isTransactionThread(parentReportAction)) {
formattedName = getTransactionReportName(parentReportAction);
Expand Down Expand Up @@ -4669,6 +4673,10 @@ function getIOUApprovedMessage(reportAction: ReportAction<typeof CONST.REPORT.AC
return Localize.translateLocal('iou.approvedAmount', {amount: getFormattedAmount(reportAction)});
}

function getJoinRequestMessage(reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST>) {
return Localize.translateLocal('workspace.inviteMessage.joinRequest', {user: ReportActionsUtils.getOriginalMessage(reportAction)?.email ?? ''});
}

/**
* We pass the reportID as older FORWARDED actions do not have the amount & currency stored in the message
* so we retrieve the amount from the report instead
Expand Down Expand Up @@ -8435,6 +8443,7 @@ export {
getRejectedReportMessage,
getWorkspaceNameUpdatedMessage,
getReportAutomaticallySubmittedMessage,
getJoinRequestMessage,
getIOUSubmittedMessage,
getIcons,
getIconsForParticipants,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,9 @@ const ContextMenuActions: ContextMenuAction[] = [
setClipboardMessage(ReportActionsUtils.getCardIssuedMessage(reportAction, true, report?.policyID, hasCard));
} else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) {
setClipboardMessage(ReportActionsUtils.getRemovedConnectionMessage(reportAction));
} else if (ReportActionsUtils.isActionableJoinRequest(reportAction)) {
const displayMessage = ReportUtils.getJoinRequestMessage(reportAction);
Clipboard.setString(displayMessage);
} else if (content) {
setClipboardMessage(
content.replace(/(<mention-user>)(.*?)(<\/mention-user>)/gi, (match, openTag: string, innerContent: string, closeTag: string): string => {
Expand Down
12 changes: 12 additions & 0 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,18 @@ function ReportActionItem({
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(action)} />;
} else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) {
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getRemovedFromApprovalChainMessage(action)} />;
} else if (ReportActionsUtils.isActionableJoinRequest(action)) {
children = (
<View>
<ReportActionItemBasicMessage message={ReportUtils.getJoinRequestMessage(action)} />
{actionableItemButtons.length > 0 && (
<ActionableItemButtons
items={actionableItemButtons}
layout={ReportActionsUtils.isActionableTrackExpense(action) ? 'vertical' : 'horizontal'}
/>
)}
</View>
);
} else if (
ReportActionsUtils.isActionOfType(
action,
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ type OriginalMessageJoinPolicyChangeLog = {

/** ID of the affected policy */
policyID: string;

/** Email of the requested user */
email?: string;
};

/** Model of `modified expense` report action */
Expand Down
Loading