Skip to content

Commit fcb7336

Browse files
authored
Merge pull request Expensify#67547 from mkzie2/mkzie2-issue/66619
fix: expense created offline for new chat shows two avatar
2 parents eb4608e + 4402f25 commit fcb7336

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/libs/ReportUtils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6779,6 +6779,8 @@ function buildOptimisticReportPreview(
67796779
childLastActorAccountID: currentUserAccountID,
67806780
childLastMoneyRequestComment: comment,
67816781
childRecentReceiptTransactionIDs: hasReceipt && !isEmptyObject(transaction) && transaction?.transactionID ? {[transaction.transactionID]: created} : undefined,
6782+
childOwnerAccountID: iouReport?.ownerAccountID,
6783+
childManagerAccountID: iouReport?.managerID,
67826784
...((isTestDriveTransaction || isTestTransaction) && !isScanRequest && {childStateNum: 2, childStatusNum: 4}),
67836785
};
67846786
}

tests/unit/ReportUtilsTest.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ describe('ReportUtils', () => {
19411941
expenseCreatedAction.childReportID = transactionThreadReport.reportID;
19421942

19431943
await Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {
1944-
currentUserAccountID: {
1944+
[currentUserAccountID]: {
19451945
accountID: currentUserAccountID,
19461946
displayName: currentUserEmail,
19471947
login: currentUserEmail,
@@ -5305,6 +5305,30 @@ describe('ReportUtils', () => {
53055305
expect(getReportStatusTranslation(undefined, CONST.REPORT.STATUS_NUM.OPEN)).toBe('');
53065306
});
53075307
});
5308+
5309+
describe('buildOptimisticReportPreview', () => {
5310+
it('should include childOwnerAccountID and childManagerAccountID that matches with iouReport data', () => {
5311+
const chatReport: Report = {
5312+
...createRandomReport(100),
5313+
type: CONST.REPORT.TYPE.CHAT,
5314+
chatType: undefined,
5315+
};
5316+
5317+
const iouReport: Report = {
5318+
...createRandomReport(200),
5319+
parentReportID: '1',
5320+
type: CONST.REPORT.TYPE.IOU,
5321+
chatType: undefined,
5322+
ownerAccountID: 1,
5323+
managerID: 2,
5324+
};
5325+
5326+
const reportPreviewAction = buildOptimisticReportPreview(chatReport, iouReport);
5327+
5328+
expect(reportPreviewAction.childOwnerAccountID).toBe(iouReport.ownerAccountID);
5329+
expect(reportPreviewAction.childManagerAccountID).toBe(iouReport.managerID);
5330+
});
5331+
});
53085332
describe('canSeeDefaultRoom', () => {
53095333
it('should return true if report is archived room ', () => {
53105334
const betas = [CONST.BETAS.DEFAULT_ROOMS];

0 commit comments

Comments
 (0)