Skip to content

Commit

Permalink
Merge pull request #54863 from bernhardoj/fix/54001-chat-not-scrolled…
Browse files Browse the repository at this point in the history
…-to-bot-when-categorizing-expense

Fix chat doesn't scroll when splitting expense
  • Loading branch information
srikarparsi authored Feb 4, 2025
2 parents d89939b + 0108af8 commit a5ba285
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
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

0 comments on commit a5ba285

Please sign in to comment.