Skip to content

Commit c3f7b6b

Browse files
authored
Merge pull request Expensify#49834 from daledah/fix/47830
fix: show correct message when disconnecting quickbooks desktop
2 parents 69483ff + bc0548a commit c3f7b6b

File tree

9 files changed

+35
-2
lines changed

9 files changed

+35
-2
lines changed

src/languages/en.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4273,6 +4273,7 @@ const translations = {
42734273
addEmployee: ({email, role}: AddEmployeeParams) => `added ${email} as ${role === 'user' ? 'member' : 'admin'}`,
42744274
updateRole: ({email, currentRole, newRole}: UpdateRoleParams) => `updated the role of ${email} from ${currentRole} to ${newRole}`,
42754275
removeMember: ({email, role}: AddEmployeeParams) => `removed ${role} ${email}`,
4276+
removedConnection: ({connectionName}: ConnectionNameParams) => `removed connection to ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]}`,
42764277
},
42774278
},
42784279
},

src/languages/es.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4319,6 +4319,7 @@ const translations = {
43194319
updateRole: ({email, currentRole, newRole}: UpdateRoleParams) =>
43204320
`actualicé el rol ${email} de ${currentRole === 'user' ? 'miembro' : 'administrador'} a ${newRole === 'user' ? 'miembro' : 'administrador'}`,
43214321
removeMember: ({email, role}: AddEmployeeParams) => `eliminado ${role === 'user' ? 'miembro' : 'administrador'} ${email}`,
4322+
removedConnection: ({connectionName}: ConnectionNameParams) => `eliminó la conexión a ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]}`,
43224323
},
43234324
},
43244325
},

src/languages/params.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type {OnyxInputOrEntry, ReportAction} from '@src/types/onyx';
22
import type {DelegateRole} from '@src/types/onyx/Account';
3-
import type {ConnectionName, PolicyConnectionSyncStage, SageIntacctMappingName, Unit} from '@src/types/onyx/Policy';
3+
import type {AllConnectionName, ConnectionName, PolicyConnectionSyncStage, SageIntacctMappingName, Unit} from '@src/types/onyx/Policy';
44
import type {ViolationDataType} from '@src/types/onyx/TransactionViolation';
55

66
type AddressLineParams = {
@@ -338,7 +338,7 @@ type ApprovalWorkflowErrorParams = {
338338
};
339339

340340
type ConnectionNameParams = {
341-
connectionName: ConnectionName;
341+
connectionName: AllConnectionName;
342342
};
343343

344344
type LastSyncDateParams = {

src/libs/ReportActionsUtils.ts

+10
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,15 @@ function getPolicyChangeLogDeleteMemberMessage(reportAction: OnyxInputOrEntry<Re
16921692
return Localize.translateLocal('report.actions.type.removeMember', {email, role});
16931693
}
16941694

1695+
function getRemovedConnectionMessage(reportAction: OnyxEntry<ReportAction>): string {
1696+
if (!isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) {
1697+
return '';
1698+
}
1699+
const originalMessage = getOriginalMessage(reportAction);
1700+
const connectionName = originalMessage?.connectionName;
1701+
return connectionName ? Localize.translateLocal('report.actions.type.removedConnection', {connectionName}) : '';
1702+
}
1703+
16951704
function getRenamedAction(reportAction: OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.RENAMED>>) {
16961705
const originalMessage = getOriginalMessage(reportAction);
16971706
return Localize.translateLocal('newRoomPage.renamedRoomAction', {
@@ -1851,6 +1860,7 @@ export {
18511860
getRenamedAction,
18521861
isCardIssuedAction,
18531862
getCardIssuedMessage,
1863+
getRemovedConnectionMessage,
18541864
};
18551865

18561866
export type {LastVisibleMessage};

src/libs/SidebarUtils.ts

+2
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ function getOptionData({
448448
result.alternateText = ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(lastAction);
449449
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE) {
450450
result.alternateText = ReportActionsUtils.getReportActionMessageText(lastAction) ?? '';
451+
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION) {
452+
result.alternateText = ReportActionsUtils.getRemovedConnectionMessage(lastAction);
451453
} else {
452454
result.alternateText =
453455
lastMessageTextFromReport.length > 0

src/pages/home/report/ContextMenu/ContextMenuActions.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ const ContextMenuActions: ContextMenuAction[] = [
478478
setClipboardMessage(Localize.translateLocal('report.actions.type.integrationSyncFailed', {label, errorMessage}));
479479
} else if (ReportActionsUtils.isCardIssuedAction(reportAction)) {
480480
setClipboardMessage(ReportActionsUtils.getCardIssuedMessage(reportAction, true));
481+
} else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) {
482+
setClipboardMessage(ReportActionsUtils.getRemovedConnectionMessage(reportAction));
481483
} else if (content) {
482484
setClipboardMessage(
483485
content.replace(/(<mention-user>)(.*?)(<\/mention-user>)/gi, (match, openTag: string, innerContent: string, closeTag: string): string => {

src/pages/home/report/ReportActionItem.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,8 @@ function ReportActionItem({
683683
} else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) {
684684
const {label, errorMessage} = ReportActionsUtils.getOriginalMessage(action) ?? {label: '', errorMessage: ''};
685685
children = <ReportActionItemBasicMessage message={translate('report.actions.type.integrationSyncFailed', {label, errorMessage})} />;
686+
} else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) {
687+
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getRemovedConnectionMessage(action)} />;
686688
} else {
687689
const hasBeenFlagged =
688690
![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) &&

src/types/onyx/OriginalMessage.ts

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {ValueOf} from 'type-fest';
22
import type CONST from '@src/CONST';
33
import type DeepValueOf from '@src/types/utils/DeepValueOf';
44
import type {OldDotOriginalMessageMap} from './OldDotAction';
5+
import type {AllConnectionName} from './Policy';
56
import type ReportActionName from './ReportActionName';
67

78
/** Types of join workspace resolutions */
@@ -274,6 +275,9 @@ type OriginalMessageChangeLog = {
274275

275276
/** Old role of user */
276277
oldValue?: string;
278+
279+
/** Name of connection */
280+
connectionName?: AllConnectionName;
277281
};
278282

279283
/** Model of `join policy changelog` report action */

src/types/onyx/Policy.ts

+11
Original file line numberDiff line numberDiff line change
@@ -1232,9 +1232,19 @@ type Connections = {
12321232
[CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT]: Connection<SageIntacctConnectionData, SageIntacctConnectionsConfig>;
12331233
};
12341234

1235+
/** All integration connections, including unsupported ones */
1236+
type AllConnections = Connections & {
1237+
/** Quickbooks Desktop integration connection */
1238+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1239+
quickbooksDesktop: any;
1240+
};
1241+
12351242
/** Names of integration connections */
12361243
type ConnectionName = keyof Connections;
12371244

1245+
/** Names of all integration connections */
1246+
type AllConnectionName = keyof AllConnections;
1247+
12381248
/** Merchant Category Code. This is a way to identify the type of merchant (and type of spend) when a credit card is swiped. */
12391249
type MccGroup = {
12401250
/** Default category for provided MCC Group */
@@ -1728,6 +1738,7 @@ export type {
17281738
Connections,
17291739
SageIntacctOfflineStateKeys,
17301740
ConnectionName,
1741+
AllConnectionName,
17311742
Tenant,
17321743
Account,
17331744
QBONonReimbursableExportAccountType,

0 commit comments

Comments
 (0)