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
5 changes: 3 additions & 2 deletions src/libs/actions/IOU/RejectMoneyRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,9 @@ function rejectExpenseReport(
const isRejectToSubmitter = targetAccountID === report.ownerAccountID;
const baseTimestamp = DateUtils.getDBTime();
const optimisticRejectAction = buildOptimisticReportLevelRejectAction(isRejectToSubmitter, currentUserAccountID, currentUserDisplayName, currentUserAvatarSource, baseTimestamp);
const parsedComment = getParsedComment(comment);
const optimisticCommentAction = buildOptimisticReportLevelRejectCommentAction(
comment,
parsedComment,
currentUserAccountID,
currentUserDisplayName,
currentUserAvatarSource,
Expand Down Expand Up @@ -1148,7 +1149,7 @@ function rejectExpenseReport(
const parameters: RejectExpenseReportParams = {
reportID,
targetAccountID,
comment,
comment: parsedComment,
rejectedActionReportActionID: optimisticRejectAction.reportActionID,
rejectedCommentReportActionID: optimisticCommentAction.reportActionID,
};
Expand Down
22 changes: 21 additions & 1 deletion tests/actions/IOUTest/RejectMoneyRequestTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {OnyxEntry} from 'react-native-onyx';
import {markRejectViolationAsResolved, rejectExpenseReport, rejectMoneyRequest} from '@libs/actions/IOU/RejectMoneyRequest';
import initOnyxDerivedValues from '@libs/actions/OnyxDerived';
import {WRITE_COMMANDS} from '@libs/API/types';
import {getParsedComment} from '@libs/ReportUtils';
import CONST from '@src/CONST';
import OnyxUpdateManager from '@src/libs/actions/OnyxUpdateManager';
import * as API from '@src/libs/API';
Expand Down Expand Up @@ -286,7 +287,26 @@ describe('actions/IOU/RejectMoneyRequest', () => {
expect.objectContaining({
reportID: expenseReport.reportID,
targetAccountID: SUBMITTER_ACCOUNT_ID,
comment,
comment: getParsedComment(comment),
}),
expect.anything(),
);
writeSpy.mockRestore();
});

it('queues getParsedComment output for REJECT_EXPENSE_REPORT when reject reason contains markdown', async () => {
const markdownComment = 'Rejected because **important**';

// eslint-disable-next-line rulesdir/no-multiple-api-calls
Comment thread
truph01 marked this conversation as resolved.
Resolved
const writeSpy = jest.spyOn(API, 'write').mockImplementation(jest.fn());

rejectExpenseReport(expenseReport, SUBMITTER_ACCOUNT_ID, markdownComment, TEST_USER_ACCOUNT_ID, CURRENT_USER_DISPLAY_NAME, CURRENT_USER_AVATAR);
await waitForBatchedUpdates();

expect(writeSpy).toHaveBeenCalledWith(
WRITE_COMMANDS.REJECT_EXPENSE_REPORT,
expect.objectContaining({
comment: getParsedComment(markdownComment),
}),
expect.anything(),
);
Expand Down
Loading