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 55705 LHN - user name disappear from ws rooms admins #55974

3 changes: 2 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import type {
LastFourDigitsParams,
LastSyncAccountingParams,
LastSyncDateParams,
LeftWorkspaceParams,
LocalTimeParams,
LoggedInAsParams,
LogSizeParams,
Expand Down Expand Up @@ -4326,7 +4327,6 @@ const translations = {
users: 'users',
invited: 'invited',
removed: 'removed',
leftWorkspace: 'left the workspace',
to: 'to',
from: 'from',
},
Expand Down Expand Up @@ -5045,6 +5045,7 @@ const translations = {
`updated the role of ${email} to ${newRole === 'member' || newRole === 'user' ? 'member' : newRole} (previously ${
currentRole === 'member' || currentRole === 'user' ? 'member' : currentRole
})`,
leftWorkspace: ({nameOrEmail}: LeftWorkspaceParams) => `${nameOrEmail} left the workspace`,
removeMember: ({email, role}: AddEmployeeParams) => `removed ${role === 'member' || role === 'user' ? 'member' : 'admin'} ${email}`,
removedConnection: ({connectionName}: ConnectionNameParams) => `removed connection to ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]}`,
},
Expand Down
3 changes: 2 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ import type {
LastFourDigitsParams,
LastSyncAccountingParams,
LastSyncDateParams,
LeftWorkspaceParams,
LocalTimeParams,
LoggedInAsParams,
LogSizeParams,
Expand Down Expand Up @@ -4371,7 +4372,6 @@ const translations = {
users: 'miembros',
invited: 'invitó',
removed: 'eliminó',
leftWorkspace: 'salió del espacio de trabajo',
to: 'a',
from: 'de',
},
Expand Down Expand Up @@ -5095,6 +5095,7 @@ const translations = {
`actualizó el rol ${email} a ${newRole === 'miembro' || newRole === 'user' ? 'miembro' : 'administrador'} (previamente ${
currentRole === 'miembro' || currentRole === 'user' ? 'miembro' : 'administrador'
})`,
leftWorkspace: ({nameOrEmail}: LeftWorkspaceParams) => `${nameOrEmail} salió del espacio de trabajo`,
removeMember: ({email, role}: AddEmployeeParams) => `eliminado ${role === 'miembro' || role === 'user' ? 'miembro' : 'administrador'} ${email}`,
removedConnection: ({connectionName}: ConnectionNameParams) => `eliminó la conexión a ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]}`,
},
Expand Down
3 changes: 3 additions & 0 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ type AddEmployeeParams = {email: string; role: string};

type UpdateRoleParams = {email: string; currentRole: string; newRole: string};

type LeftWorkspaceParams = {nameOrEmail: string};

type RemoveMemberParams = {email: string; role: string};

type DateParams = {date: string};
Expand Down Expand Up @@ -799,6 +801,7 @@ export type {
IntegrationSyncFailedParams,
AddEmployeeParams,
UpdateRoleParams,
LeftWorkspaceParams,
RemoveMemberParams,
DateParams,
FiltersAmountBetweenParams,
Expand Down
17 changes: 16 additions & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ function getMemberChangeMessageElements(reportAction: OnyxEntry<ReportAction>):
}

if (isLeaveAction) {
verb = translateLocal('workspace.invite.leftWorkspace');
verb = getPolicyChangeLogEmployeeLeftMessage(reportAction);
}

const originalMessage = getOriginalMessage(reportAction);
Expand Down Expand Up @@ -1768,6 +1768,20 @@ function getPolicyChangeLogChangeRoleMessage(reportAction: OnyxInputOrEntry<Repo
return translateLocal('report.actions.type.updateRole', {email, newRole, currentRole: oldRole});
}

function getPolicyChangeLogEmployeeLeftMessage(reportAction: ReportAction, useName = false): string {
if (!isLeavePolicyAction(reportAction)) {
return '';
}
const originalMessage = getOriginalMessage(reportAction);
const personalDetails = getPersonalDetailsByIDs({accountIDs: reportAction.actorAccountID ? [reportAction.actorAccountID] : [], currentUserAccountID: 0})?.at(0);
if (!!originalMessage && !originalMessage.email) {
originalMessage.email = personalDetails?.login;
}
const nameOrEmail = useName && !!personalDetails?.firstName ? `${personalDetails?.firstName}:` : originalMessage?.email ?? '';
const formattedNameOrEmail = formatPhoneNumber(nameOrEmail);
return translateLocal('report.actions.type.leftWorkspace', {nameOrEmail: formattedNameOrEmail});
}

function isPolicyChangeLogDeleteMemberMessage(
reportAction: OnyxInputOrEntry<ReportAction>,
): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE> {
Expand Down Expand Up @@ -2023,6 +2037,7 @@ export {
getPolicyChangeLogAddEmployeeMessage,
getPolicyChangeLogChangeRoleMessage,
getPolicyChangeLogDeleteMemberMessage,
getPolicyChangeLogEmployeeLeftMessage,
getRenamedAction,
isCardIssuedAction,
getCardIssuedMessage,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
getPolicyChangeLogAddEmployeeMessage,
getPolicyChangeLogChangeRoleMessage,
getPolicyChangeLogDeleteMemberMessage,
getPolicyChangeLogEmployeeLeftMessage,
getRemovedConnectionMessage,
getRenamedAction,
getReportAction,
Expand Down Expand Up @@ -538,7 +539,7 @@ function getOptionData({
} else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME)) {
result.alternateText = getWorkspaceNameUpdatedMessage(lastAction);
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) {
result.alternateText = translateLocal('workspace.invite.leftWorkspace');
result.alternateText = getPolicyChangeLogEmployeeLeftMessage(lastAction, true);
} else if (isCardIssuedAction(lastAction)) {
result.alternateText = getCardIssuedMessage({reportAction: lastAction});
} else if (lastAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && lastActorDisplayName && lastMessageTextFromReport) {
Expand Down