diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ab791f22efd7..a97972d730e6 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6752,6 +6752,8 @@ function buildOptimisticReportPreview( childLastActorAccountID: currentUserAccountID, childLastMoneyRequestComment: comment, childRecentReceiptTransactionIDs: hasReceipt && !isEmptyObject(transaction) && transaction?.transactionID ? {[transaction.transactionID]: created} : undefined, + childOwnerAccountID: iouReport?.ownerAccountID, + childManagerAccountID: iouReport?.managerID, ...((isTestDriveTransaction || isTestTransaction) && !isScanRequest && {childStateNum: 2, childStatusNum: 4}), }; } diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index af4603de155a..78ef22a68af5 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -1941,7 +1941,7 @@ describe('ReportUtils', () => { expenseCreatedAction.childReportID = transactionThreadReport.reportID; await Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, { - currentUserAccountID: { + [currentUserAccountID]: { accountID: currentUserAccountID, displayName: currentUserEmail, login: currentUserEmail, @@ -5278,6 +5278,30 @@ describe('ReportUtils', () => { expect(getReportStatusTranslation(undefined, CONST.REPORT.STATUS_NUM.OPEN)).toBe(''); }); }); + + describe('buildOptimisticReportPreview', () => { + it('should include childOwnerAccountID and childManagerAccountID that matches with iouReport data', () => { + const chatReport: Report = { + ...createRandomReport(100), + type: CONST.REPORT.TYPE.CHAT, + chatType: undefined, + }; + + const iouReport: Report = { + ...createRandomReport(200), + parentReportID: '1', + type: CONST.REPORT.TYPE.IOU, + chatType: undefined, + ownerAccountID: 1, + managerID: 2, + }; + + const reportPreviewAction = buildOptimisticReportPreview(chatReport, iouReport); + + expect(reportPreviewAction.childOwnerAccountID).toBe(iouReport.ownerAccountID); + expect(reportPreviewAction.childManagerAccountID).toBe(iouReport.managerID); + }); + }); describe('canSeeDefaultRoom', () => { it('should return true if report is archived room ', () => { const betas = [CONST.BETAS.DEFAULT_ROOMS];