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
8 changes: 5 additions & 3 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ import type * as OnyxTypes from '@src/types/onyx';
import type {Attendee, Participant, Split} from '@src/types/onyx/IOU';
import type {ErrorFields, Errors} from '@src/types/onyx/OnyxCommon';
import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage';
import type {QuickActionName} from '@src/types/onyx/QuickAction';
import type {InvoiceReceiver, InvoiceReceiverType} from '@src/types/onyx/Report';
import type ReportAction from '@src/types/onyx/ReportAction';
import type {OnyxData} from '@src/types/onyx/Request';
Expand Down Expand Up @@ -1882,11 +1883,12 @@ function buildOnyxDataForTrackExpense(
const successData: OnyxUpdate[] = [];
const failureData: OnyxUpdate[] = [];

let newQuickAction: ValueOf<typeof CONST.QUICK_ACTIONS> = CONST.QUICK_ACTIONS.TRACK_MANUAL;
const isSelfDMReport = isSelfDM(chatReport);
let newQuickAction: QuickActionName = isSelfDMReport ? CONST.QUICK_ACTIONS.TRACK_MANUAL : CONST.QUICK_ACTIONS.REQUEST_MANUAL;
if (isScanRequest) {
newQuickAction = CONST.QUICK_ACTIONS.TRACK_SCAN;
newQuickAction = isSelfDMReport ? CONST.QUICK_ACTIONS.TRACK_SCAN : CONST.QUICK_ACTIONS.REQUEST_SCAN;
} else if (isDistanceRequest) {
newQuickAction = CONST.QUICK_ACTIONS.TRACK_DISTANCE;
newQuickAction = isSelfDMReport ? CONST.QUICK_ACTIONS.TRACK_DISTANCE : CONST.QUICK_ACTIONS.REQUEST_DISTANCE;
}
const existingTransactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${existingTransactionThreadReportID}`] ?? null;

Expand Down
19 changes: 17 additions & 2 deletions tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe('actions/IOU', () => {
};

// Given a policyExpenseChat report
const expenseReport = {
const policyExpenseChat = {
...createRandomReport(1),
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
};
Expand Down Expand Up @@ -290,7 +290,7 @@ describe('actions/IOU', () => {

// When the user confirms the category for the tracked expense
trackExpense({
report: expenseReport,
report: policyExpenseChat,
isDraftPolicy: false,
action: CONST.IOU.ACTION.CATEGORIZE,
participantParams: {
Expand Down Expand Up @@ -337,6 +337,21 @@ describe('actions/IOU', () => {
},
});
});

await new Promise<void>((resolve) => {
const connection = Onyx.connect({
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
callback: (quickAction) => {
Onyx.disconnect(connection);
resolve();

// Then the quickAction.action should be set to REQUEST_DISTANCE
expect(quickAction?.action).toBe(CONST.QUICK_ACTIONS.REQUEST_DISTANCE);
// Then the quickAction.chatReportID should be set to the given policyExpenseChat reportID
expect(quickAction?.chatReportID).toBe(policyExpenseChat.reportID);
},
});
});
});
});

Expand Down