Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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
7 changes: 4 additions & 3 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1882,11 +1882,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: ValueOf<typeof CONST.QUICK_ACTIONS> = 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 @@ -163,7 +163,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 @@ -279,7 +279,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 @@ -326,6 +326,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
Loading