Skip to content

Commit 459759d

Browse files
authored
Merge pull request #46721 from cretadn22/add-parent-report-action-id
Add parentReportActionID to new expense report on the approve flow
2 parents 17cd380 + 2035634 commit 459759d

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/libs/ReportUtils.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4097,8 +4097,17 @@ function buildOptimisticInvoiceReport(chatReportID: string, policyID: string, re
40974097
* @param total - Amount in cents
40984098
* @param currency
40994099
* @param reimbursable – Whether the expense is reimbursable
4100+
* @param parentReportActionID – The parent ReportActionID of the PolicyExpenseChat
41004101
*/
4101-
function buildOptimisticExpenseReport(chatReportID: string, policyID: string, payeeAccountID: number, total: number, currency: string, reimbursable = true): OptimisticExpenseReport {
4102+
function buildOptimisticExpenseReport(
4103+
chatReportID: string,
4104+
policyID: string,
4105+
payeeAccountID: number,
4106+
total: number,
4107+
currency: string,
4108+
reimbursable = true,
4109+
parentReportActionID?: string,
4110+
): OptimisticExpenseReport {
41024111
// The amount for Expense reports are stored as negative value in the database
41034112
const storedTotal = total * -1;
41044113
const policyName = getPolicyName(ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`]);
@@ -4126,6 +4135,7 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa
41264135
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
41274136
parentReportID: chatReportID,
41284137
lastVisibleActionCreated: DateUtils.getDBTime(),
4138+
parentReportActionID,
41294139
};
41304140

41314141
// Get the approver/manager for this report to properly display the optimistic data
@@ -4472,19 +4482,21 @@ function buildOptimisticSubmittedReportAction(amount: number, currency: string,
44724482
* @param iouReport
44734483
* @param [comment] - User comment for the IOU.
44744484
* @param [transaction] - optimistic first transaction of preview
4485+
* @param reportActionID
44754486
*/
44764487
function buildOptimisticReportPreview(
44774488
chatReport: OnyxInputOrEntry<Report>,
44784489
iouReport: Report,
44794490
comment = '',
44804491
transaction: OnyxInputOrEntry<Transaction> = null,
44814492
childReportID?: string,
4493+
reportActionID?: string,
44824494
): ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW> {
44834495
const hasReceipt = TransactionUtils.hasReceipt(transaction);
44844496
const message = getReportPreviewMessage(iouReport);
44854497
const created = DateUtils.getDBTime();
44864498
return {
4487-
reportActionID: NumberUtils.rand64(),
4499+
reportActionID: reportActionID ?? NumberUtils.rand64(),
44884500
reportID: chatReport?.reportID,
44894501
actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW,
44904502
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,

src/libs/actions/IOU.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6249,6 +6249,7 @@ function getReportFromHoldRequestsOnyxData(
62496249
} {
62506250
const {holdReportActions, holdTransactions} = getHoldReportActionsAndTransactions(iouReport.reportID);
62516251
const firstHoldTransaction = holdTransactions[0];
6252+
const newParentReportActionID = rand64();
62526253

62536254
const optimisticExpenseReport = ReportUtils.buildOptimisticExpenseReport(
62546255
chatReport.reportID,
@@ -6257,8 +6258,16 @@ function getReportFromHoldRequestsOnyxData(
62576258
(firstHoldTransaction?.amount ?? 0) * -1,
62586259
getCurrency(firstHoldTransaction),
62596260
false,
6261+
newParentReportActionID,
6262+
);
6263+
const optimisticExpenseReportPreview = ReportUtils.buildOptimisticReportPreview(
6264+
chatReport,
6265+
optimisticExpenseReport,
6266+
'',
6267+
firstHoldTransaction,
6268+
optimisticExpenseReport.reportID,
6269+
newParentReportActionID,
62606270
);
6261-
const optimisticExpenseReportPreview = ReportUtils.buildOptimisticReportPreview(chatReport, optimisticExpenseReport, '', firstHoldTransaction, optimisticExpenseReport.reportID);
62626271

62636272
const updateHeldReports: Record<string, Pick<OnyxTypes.Report, 'parentReportActionID' | 'parentReportID' | 'chatReportID'>> = {};
62646273
const addHoldReportActions: OnyxTypes.ReportActions = {};

0 commit comments

Comments
 (0)