Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR
value: {
...chat.report,
lastReadTime: DateUtils.getDBTime(),
...(shouldCreateNewMoneyRequestReport ? {lastVisibleActionCreated: chat.reportPreviewAction.created} : {}),
iouReportID: iou.report.reportID,
...outstandingChildRequest,
...(isNewChatReport ? {pendingFields: {createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}} : {}),
Expand Down Expand Up @@ -1278,6 +1279,7 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR
value: {
iouReportID: chat.report?.iouReportID,
lastReadTime: chat.report?.lastReadTime,
lastVisibleActionCreated: chat.report?.lastVisibleActionCreated,
pendingFields: null,
hasOutstandingChildRequest: chat.report?.hasOutstandingChildRequest,
...(isNewChatReport
Expand Down
43 changes: 43 additions & 0 deletions tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1750,6 +1750,49 @@ describe('actions/IOU', () => {
}),
);
});

it('should update split chat report lastVisibleActionCreated to the report preview action', async () => {
// Given a workspace chat with no expenses
const workspaceReportID = '1';
await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${workspaceReportID}`, {reportID: workspaceReportID, isOwnPolicyExpenseChat: true});

// When the user split bill on the workspace
splitBill({
participants: [{reportID: workspaceReportID}],
currentUserLogin: RORY_EMAIL,
currentUserAccountID: RORY_ACCOUNT_ID,
comment: '',
amount: 100,
currency: CONST.CURRENCY.USD,
merchant: 'test',
created: '',
existingSplitChatReportID: workspaceReportID,
});

await waitForBatchedUpdates();

// Then the workspace chat lastVisibleActionCreated should be updated to the report preview action created
const reportPreviewAction = await new Promise<OnyxEntry<ReportAction>>((resolve) => {
const connection = Onyx.connect({
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${workspaceReportID}`,
callback: (reportActions) => {
Onyx.disconnect(connection);
resolve(Object.values(reportActions ?? {}).find((action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW));
},
});
});

await new Promise<OnyxEntry<Report>>((resolve) => {
const connection = Onyx.connect({
key: `${ONYXKEYS.COLLECTION.REPORT}${workspaceReportID}`,
callback: (report) => {
Onyx.disconnect(connection);
expect(report?.lastVisibleActionCreated).toBe(reportPreviewAction?.created);
resolve(report);
},
});
});
});
});

describe('payMoneyRequestElsewhere', () => {
Expand Down