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: 1 addition & 7 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ import {
getTrackExpenseActionableWhisper,
isActionableTrackExpense,
isCreatedAction,
isDeletedAction,
isMoneyRequestAction,
isReportPreviewAction,
} from '@libs/ReportActionsUtils';
Expand Down Expand Up @@ -9240,12 +9239,7 @@ function getIOUReportActionToApproveOrPay(chatReport: OnyxEntry<OnyxTypes.Report
// eslint-disable-next-line deprecation/deprecation
const policy = getPolicy(iouReport?.policyID);
const shouldShowSettlementButton = canIOUBePaid(iouReport, chatReport, policy) || canApproveIOU(iouReport, policy);
return (
action.childReportID?.toString() !== excludedIOUReportID &&
action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW &&
shouldShowSettlementButton &&
!isDeletedAction(action)
);
return action.childReportID?.toString() !== excludedIOUReportID && action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && shouldShowSettlementButton;
});
}

Expand Down
78 changes: 0 additions & 78 deletions tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
canUnapproveIOU,
createDistanceRequest,
deleteMoneyRequest,
getIOUReportActionToApproveOrPay,
initMoneyRequest,
initSplitExpense,
payMoneyRequest,
Expand Down Expand Up @@ -6399,81 +6398,4 @@ describe('actions/IOU', () => {
});
});
});

describe('getIOUReportActionToApproveOrPay', () => {
it('should exclude deleted actions', async () => {
const reportID = '1';
const policyID = '2';
const fakePolicy: Policy = {
...createRandomPolicy(Number(policyID)),
approvalMode: CONST.POLICY.APPROVAL_MODE.BASIC,
};

const fakeReport: Report = {
...createRandomReport(Number(reportID)),
type: CONST.REPORT.TYPE.EXPENSE,
policyID,
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
managerID: RORY_ACCOUNT_ID,
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
};
const fakeTransaction1: Transaction = {
...createRandomTransaction(0),
reportID,
bank: CONST.EXPENSIFY_CARD.BANK,
status: CONST.TRANSACTION.STATUS.PENDING,
};
const fakeTransaction2: Transaction = {
...createRandomTransaction(1),
reportID,
amount: 27,
receipt: {
source: 'test',
state: CONST.IOU.RECEIPT_STATE.SCAN_FAILED,
},
merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT,
modifiedMerchant: undefined,
};
const fakeTransaction3: Transaction = {
...createRandomTransaction(2),
reportID,
amount: 100,
};

await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${fakeReport.reportID}`, fakeReport);
await Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${fakeTransaction1.transactionID}`, fakeTransaction1);
await Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${fakeTransaction2.transactionID}`, fakeTransaction2);
await Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${fakeTransaction3.transactionID}`, fakeTransaction3);
await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, fakePolicy);
await waitForBatchedUpdates();

const deletedReportAction = {
reportActionID: '0',
actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW,
created: '2024-08-08 18:70:44.171',
childReportID: reportID,
};

const MOCK_REPORT_ACTIONS: ReportActions = {
[deletedReportAction.reportActionID]: deletedReportAction,
[reportID]: {
reportActionID: reportID,
actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW,
created: '2024-08-08 19:70:44.171',
childReportID: reportID,
message: [
{
type: 'TEXT',
text: 'Hello world!',
},
],
},
};

await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${fakeReport.reportID}`, MOCK_REPORT_ACTIONS);

expect(getIOUReportActionToApproveOrPay(fakeReport, undefined)).toMatchObject(MOCK_REPORT_ACTIONS[reportID]);
});
});
});
12 changes: 0 additions & 12 deletions tests/unit/DebugUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1077,25 +1077,13 @@ describe('DebugUtils', () => {
reportActionID: '0',
actionName: CONST.REPORT.ACTIONS.TYPE.CREATED,
created: '2024-08-08 18:70:44.171',
message: [
{
type: 'TEXT',
text: 'Hello world!',
},
],
},
// eslint-disable-next-line @typescript-eslint/naming-convention
'1': {
reportActionID: '1',
actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW,
created: '2024-08-08 19:70:44.171',
childReportID: '2',
message: [
{
type: 'TEXT',
text: 'Hello world!',
},
],
},
};
await Onyx.multiSet({
Expand Down