Skip to content

Commit 4a8d384

Browse files
committed
fix: expense created offline for new chat shows two avatar
1 parent fbc5bec commit 4a8d384

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/libs/ReportUtils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6675,6 +6675,8 @@ function buildOptimisticReportPreview(
66756675
childLastActorAccountID: currentUserAccountID,
66766676
childLastMoneyRequestComment: comment,
66776677
childRecentReceiptTransactionIDs: hasReceipt && !isEmptyObject(transaction) && transaction?.transactionID ? {[transaction.transactionID]: created} : undefined,
6678+
childOwnerAccountID: iouReport?.ownerAccountID,
6679+
childManagerAccountID: iouReport?.managerID,
66786680
...((isTestDriveTransaction || isTestTransaction) && !isScanRequest && {childStateNum: 2, childStatusNum: 4}),
66796681
};
66806682
}

tests/unit/ReportUtilsTest.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4978,4 +4978,28 @@ describe('ReportUtils', () => {
49784978
expect(getReportStatusTranslation(undefined, CONST.REPORT.STATUS_NUM.OPEN)).toBe('');
49794979
});
49804980
});
4981+
4982+
describe('buildOptimisticReportPreview', () => {
4983+
it('should include childOwnerAccountID and childManagerAccountID that matches with iouReport data', () => {
4984+
const chatReport: Report = {
4985+
...createRandomReport(1),
4986+
type: CONST.REPORT.TYPE.CHAT,
4987+
chatType: undefined,
4988+
};
4989+
4990+
const iouReport: Report = {
4991+
...createRandomReport(2),
4992+
parentReportID: '1',
4993+
type: CONST.REPORT.TYPE.IOU,
4994+
chatType: undefined,
4995+
ownerAccountID: 1,
4996+
managerID: 2,
4997+
};
4998+
4999+
const reportPreviewAction = buildOptimisticReportPreview(chatReport, iouReport);
5000+
5001+
expect(reportPreviewAction.childOwnerAccountID).toBe(iouReport.ownerAccountID);
5002+
expect(reportPreviewAction.childManagerAccountID).toBe(iouReport.managerID);
5003+
});
5004+
});
49815005
});

0 commit comments

Comments
 (0)