Skip to content

Commit

Permalink
Merge pull request Expensify#49834 from daledah/fix/47830
Browse files Browse the repository at this point in the history
fix: show correct message when disconnecting quickbooks desktop
  • Loading branch information
lakchote authored Oct 1, 2024
2 parents 69483ff + bc0548a commit c3f7b6b
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4273,6 +4273,7 @@ const translations = {
addEmployee: ({email, role}: AddEmployeeParams) => `added ${email} as ${role === 'user' ? 'member' : 'admin'}`,
updateRole: ({email, currentRole, newRole}: UpdateRoleParams) => `updated the role of ${email} from ${currentRole} to ${newRole}`,
removeMember: ({email, role}: AddEmployeeParams) => `removed ${role} ${email}`,
removedConnection: ({connectionName}: ConnectionNameParams) => `removed connection to ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]}`,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4319,6 +4319,7 @@ const translations = {
updateRole: ({email, currentRole, newRole}: UpdateRoleParams) =>
`actualicé el rol ${email} de ${currentRole === 'user' ? 'miembro' : 'administrador'} a ${newRole === 'user' ? 'miembro' : 'administrador'}`,
removeMember: ({email, role}: AddEmployeeParams) => `eliminado ${role === 'user' ? 'miembro' : 'administrador'} ${email}`,
removedConnection: ({connectionName}: ConnectionNameParams) => `eliminó la conexión a ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]}`,
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {OnyxInputOrEntry, ReportAction} from '@src/types/onyx';
import type {DelegateRole} from '@src/types/onyx/Account';
import type {ConnectionName, PolicyConnectionSyncStage, SageIntacctMappingName, Unit} from '@src/types/onyx/Policy';
import type {AllConnectionName, ConnectionName, PolicyConnectionSyncStage, SageIntacctMappingName, Unit} from '@src/types/onyx/Policy';
import type {ViolationDataType} from '@src/types/onyx/TransactionViolation';

type AddressLineParams = {
Expand Down Expand Up @@ -338,7 +338,7 @@ type ApprovalWorkflowErrorParams = {
};

type ConnectionNameParams = {
connectionName: ConnectionName;
connectionName: AllConnectionName;
};

type LastSyncDateParams = {
Expand Down
10 changes: 10 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,15 @@ function getPolicyChangeLogDeleteMemberMessage(reportAction: OnyxInputOrEntry<Re
return Localize.translateLocal('report.actions.type.removeMember', {email, role});
}

function getRemovedConnectionMessage(reportAction: OnyxEntry<ReportAction>): string {
if (!isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) {
return '';
}
const originalMessage = getOriginalMessage(reportAction);
const connectionName = originalMessage?.connectionName;
return connectionName ? Localize.translateLocal('report.actions.type.removedConnection', {connectionName}) : '';
}

function getRenamedAction(reportAction: OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.RENAMED>>) {
const originalMessage = getOriginalMessage(reportAction);
return Localize.translateLocal('newRoomPage.renamedRoomAction', {
Expand Down Expand Up @@ -1851,6 +1860,7 @@ export {
getRenamedAction,
isCardIssuedAction,
getCardIssuedMessage,
getRemovedConnectionMessage,
};

export type {LastVisibleMessage};
2 changes: 2 additions & 0 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ function getOptionData({
result.alternateText = ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(lastAction);
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE) {
result.alternateText = ReportActionsUtils.getReportActionMessageText(lastAction) ?? '';
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION) {
result.alternateText = ReportActionsUtils.getRemovedConnectionMessage(lastAction);
} else {
result.alternateText =
lastMessageTextFromReport.length > 0
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ const ContextMenuActions: ContextMenuAction[] = [
setClipboardMessage(Localize.translateLocal('report.actions.type.integrationSyncFailed', {label, errorMessage}));
} else if (ReportActionsUtils.isCardIssuedAction(reportAction)) {
setClipboardMessage(ReportActionsUtils.getCardIssuedMessage(reportAction, true));
} else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) {
setClipboardMessage(ReportActionsUtils.getRemovedConnectionMessage(reportAction));
} else if (content) {
setClipboardMessage(
content.replace(/(<mention-user>)(.*?)(<\/mention-user>)/gi, (match, openTag: string, innerContent: string, closeTag: string): string => {
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,8 @@ function ReportActionItem({
} else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) {
const {label, errorMessage} = ReportActionsUtils.getOriginalMessage(action) ?? {label: '', errorMessage: ''};
children = <ReportActionItemBasicMessage message={translate('report.actions.type.integrationSyncFailed', {label, errorMessage})} />;
} else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) {
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getRemovedConnectionMessage(action)} />;
} else {
const hasBeenFlagged =
![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) &&
Expand Down
4 changes: 4 additions & 0 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {ValueOf} from 'type-fest';
import type CONST from '@src/CONST';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
import type {OldDotOriginalMessageMap} from './OldDotAction';
import type {AllConnectionName} from './Policy';
import type ReportActionName from './ReportActionName';

/** Types of join workspace resolutions */
Expand Down Expand Up @@ -274,6 +275,9 @@ type OriginalMessageChangeLog = {

/** Old role of user */
oldValue?: string;

/** Name of connection */
connectionName?: AllConnectionName;
};

/** Model of `join policy changelog` report action */
Expand Down
11 changes: 11 additions & 0 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1232,9 +1232,19 @@ type Connections = {
[CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT]: Connection<SageIntacctConnectionData, SageIntacctConnectionsConfig>;
};

/** All integration connections, including unsupported ones */
type AllConnections = Connections & {
/** Quickbooks Desktop integration connection */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
quickbooksDesktop: any;
};

/** Names of integration connections */
type ConnectionName = keyof Connections;

/** Names of all integration connections */
type AllConnectionName = keyof AllConnections;

/** Merchant Category Code. This is a way to identify the type of merchant (and type of spend) when a credit card is swiped. */
type MccGroup = {
/** Default category for provided MCC Group */
Expand Down Expand Up @@ -1728,6 +1738,7 @@ export type {
Connections,
SageIntacctOfflineStateKeys,
ConnectionName,
AllConnectionName,
Tenant,
Account,
QBONonReimbursableExportAccountType,
Expand Down

0 comments on commit c3f7b6b

Please sign in to comment.