Skip to content

Commit 9db8aa1

Browse files
MelvinBotdeetergp
andcommitted
Extract buildParticipants helper to eliminate duplication
Co-authored-by: Scott Deeter <deetergp@users.noreply.github.com>
1 parent 06f3a9b commit 9db8aa1

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

src/pages/iou/request/step/IOURequestStepReport.tsx

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,22 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) {
105105
}
106106
};
107107

108+
const buildParticipants = (report: OnyxEntry<Report>) => [
109+
{
110+
selected: true,
111+
accountID: 0,
112+
isPolicyExpenseChat: true,
113+
reportID: report?.chatReportID,
114+
policyID: report?.policyID,
115+
},
116+
];
117+
108118
const handleGlobalCreateReport = (item: TransactionGroupListItem) => {
109119
if (!transaction) {
110120
return;
111121
}
112122
const reportOrDraftReportFromValue = getReportOrDraftReport(item.value);
113-
const participants = [
114-
{
115-
selected: true,
116-
accountID: 0,
117-
isPolicyExpenseChat: true,
118-
reportID: reportOrDraftReportFromValue?.chatReportID,
119-
policyID: reportOrDraftReportFromValue?.policyID,
120-
},
121-
];
123+
const participants = buildParticipants(reportOrDraftReportFromValue);
122124

123125
const currentPolicyID = perDiemOriginalPolicy?.id;
124126
const newPolicyID = reportOrDraftReportFromValue?.policyID;
@@ -169,15 +171,7 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) {
169171
// eslint-disable-next-line @typescript-eslint/no-deprecated
170172
InteractionManager.runAfterInteractions(() => {
171173
Navigation.setNavigationActionToMicrotaskQueue(() => {
172-
const participants = [
173-
{
174-
selected: true,
175-
accountID: 0,
176-
isPolicyExpenseChat: true,
177-
reportID: report?.chatReportID,
178-
policyID: report?.policyID,
179-
},
180-
];
174+
const participants = buildParticipants(report);
181175

182176
setTransactionReport(
183177
transaction.transactionID,

0 commit comments

Comments
 (0)