Skip to content

Commit cc6a58d

Browse files
author
gijoe0295
committed
fix: default for inexistent ids lint
1 parent dd3968e commit cc6a58d

File tree

2 files changed

+44
-24
lines changed

2 files changed

+44
-24
lines changed

src/components/BrokenConnectionDescription.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,18 @@ function BrokenConnectionDescription({transactionID, policy, report}: BrokenConn
4040
return translate('violations.brokenConnection530Error');
4141
}
4242

43-
if (isPolicyAdmin && !ReportUtils.isCurrentUserSubmitter(report?.reportID ?? '')) {
43+
if (isPolicyAdmin && !ReportUtils.isCurrentUserSubmitter(report?.reportID)) {
4444
return (
4545
<>
4646
{`${translate('violations.adminBrokenConnectionError')}`}
4747
<TextLink
4848
style={[styles.textLabelSupporting, styles.link]}
49-
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(policy?.id ?? '-1'))}
49+
onPress={() => {
50+
if (!policy) {
51+
return;
52+
}
53+
Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(policy?.id));
54+
}}
5055
>{`${translate('workspace.common.companyCards')}`}</TextLink>
5156
.
5257
</>

src/libs/actions/Transaction.ts

+37-22
Original file line numberDiff line numberDiff line change
@@ -355,21 +355,26 @@ function updateWaypoints(transactionID: string, waypoints: WaypointCollection, i
355355
function dismissDuplicateTransactionViolation(transactionIDs: string[], dissmissedPersonalDetails: PersonalDetails) {
356356
const currentTransactionViolations = transactionIDs.map((id) => ({transactionID: id, violations: allTransactionViolation?.[id] ?? []}));
357357
const currentTransactions = transactionIDs.map((id) => allTransactions?.[id]);
358-
const transactionsReportActions = currentTransactions.map((transaction) => ReportActionsUtils.getIOUActionForReportID(transaction.reportID ?? '', transaction.transactionID ?? ''));
358+
const transactionsReportActions = currentTransactions.map((transaction) => ReportActionsUtils.getIOUActionForReportID(transaction.reportID, transaction.transactionID));
359359
const optimisticDissmidedViolationReportActions = transactionsReportActions.map(() => {
360360
return buildOptimisticDismissedViolationReportAction({reason: 'manual', violationName: CONST.VIOLATIONS.DUPLICATED_TRANSACTION});
361361
});
362362

363363
const optimisticData: OnyxUpdate[] = [];
364364
const failureData: OnyxUpdate[] = [];
365365

366-
const optimisticReportActions: OnyxUpdate[] = transactionsReportActions.map((action, index) => ({
367-
onyxMethod: Onyx.METHOD.MERGE,
368-
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${action?.childReportID ?? '-1'}`,
369-
value: {
370-
[optimisticDissmidedViolationReportActions.at(index)?.reportActionID ?? '']: optimisticDissmidedViolationReportActions.at(index) as ReportAction,
371-
},
372-
}));
366+
const optimisticReportActions: OnyxUpdate[] = transactionsReportActions.map((action, index) => {
367+
const optimisticDissmidedViolationReportAction = optimisticDissmidedViolationReportActions.at(index);
368+
return {
369+
onyxMethod: Onyx.METHOD.MERGE,
370+
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${action?.childReportID}`,
371+
value: optimisticDissmidedViolationReportAction
372+
? {
373+
[optimisticDissmidedViolationReportAction.reportActionID]: optimisticDissmidedViolationReportAction as ReportAction,
374+
}
375+
: undefined,
376+
};
377+
});
373378
const optimisticDataTransactionViolations: OnyxUpdate[] = currentTransactionViolations.map((transactionViolations) => ({
374379
onyxMethod: Onyx.METHOD.MERGE,
375380
key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionViolations.transactionID}`,
@@ -411,25 +416,35 @@ function dismissDuplicateTransactionViolation(transactionIDs: string[], dissmiss
411416
},
412417
}));
413418

414-
const failureReportActions: OnyxUpdate[] = transactionsReportActions.map((action, index) => ({
415-
onyxMethod: Onyx.METHOD.MERGE,
416-
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${action?.childReportID ?? '-1'}`,
417-
value: {
418-
[optimisticDissmidedViolationReportActions.at(index)?.reportActionID ?? '']: null,
419-
},
420-
}));
419+
const failureReportActions: OnyxUpdate[] = transactionsReportActions.map((action, index) => {
420+
const optimisticDissmidedViolationReportAction = optimisticDissmidedViolationReportActions.at(index);
421+
return {
422+
onyxMethod: Onyx.METHOD.MERGE,
423+
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${action?.childReportID}`,
424+
value: optimisticDissmidedViolationReportAction
425+
? {
426+
[optimisticDissmidedViolationReportAction.reportActionID]: null,
427+
}
428+
: undefined,
429+
};
430+
});
421431

422432
failureData.push(...failureDataTransactionViolations);
423433
failureData.push(...failureDataTransaction);
424434
failureData.push(...failureReportActions);
425435

426-
const successData: OnyxUpdate[] = transactionsReportActions.map((action, index) => ({
427-
onyxMethod: Onyx.METHOD.MERGE,
428-
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${action?.childReportID ?? '-1'}`,
429-
value: {
430-
[optimisticDissmidedViolationReportActions.at(index)?.reportActionID ?? '']: null,
431-
},
432-
}));
436+
const successData: OnyxUpdate[] = transactionsReportActions.map((action, index) => {
437+
const optimisticDissmidedViolationReportAction = optimisticDissmidedViolationReportActions.at(index);
438+
return {
439+
onyxMethod: Onyx.METHOD.MERGE,
440+
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${action?.childReportID}`,
441+
value: optimisticDissmidedViolationReportAction
442+
? {
443+
[optimisticDissmidedViolationReportAction.reportActionID]: null,
444+
}
445+
: undefined,
446+
};
447+
});
433448
// We are creating duplicate resolved report actions for each duplicate transactions and all the report actions
434449
// should be correctly linked with their parent report but the BE is sometimes linking report actions to different
435450
// parent reports than the one we set optimistically, resulting in duplicate report actions. Therefore, we send the BE

0 commit comments

Comments
 (0)