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
22 changes: 22 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,22 @@ function isMoneyRequestReport(reportOrID: OnyxInputOrEntry<Report> | string): bo
return isIOUReport(report) || isExpenseReport(report);
}

/**
* Checks if a report contains only Non-Reimbursable transactions
*/
function hasOnlyNonReimbursableTransactions(iouReportID: string | undefined): boolean {
if (!iouReportID) {
return false;
}

const transactions = TransactionUtils.getAllReportTransactions(iouReportID);
if (!transactions || transactions.length === 0) {
return false;
}

return transactions.every((transaction) => !TransactionUtils.getReimbursable(transaction));
}

/**
* Checks if a report has only one transaction associated with it
*/
Expand Down Expand Up @@ -1553,6 +1569,11 @@ function canAddOrDeleteTransactions(moneyRequestReport: OnyxEntry<Report>): bool
return false;
}

const policy = getPolicy(moneyRequestReport?.policyID);
if (PolicyUtils.isInstantSubmitEnabled(policy) && PolicyUtils.isSubmitAndClose(policy) && hasOnlyNonReimbursableTransactions(moneyRequestReport?.reportID)) {
return false;
}

if (isReportApproved(moneyRequestReport) || isSettled(moneyRequestReport?.reportID)) {
return false;
}
Expand Down Expand Up @@ -7383,6 +7404,7 @@ export {
getChatUsedForOnboarding,
findPolicyExpenseChatByPolicyID,
isIndividualInvoiceRoom,
hasOnlyNonReimbursableTransactions,
};

export type {
Expand Down
8 changes: 8 additions & 0 deletions src/libs/TransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,13 @@ function getDistance(transaction: OnyxInputOrEntry<Transaction>): number {
return transaction?.comment?.customUnit?.quantity ?? 0;
}

/**
* Return the reimbursable value. Defaults to true to match BE logic.
*/
function getReimbursable(transaction: Transaction): boolean {
return transaction?.reimbursable ?? true;
}

/**
* Return the mccGroup field from the transaction, return the modifiedMCCGroup if present.
*/
Expand Down Expand Up @@ -878,6 +885,7 @@ export {
isCustomUnitRateIDForP2P,
getRateID,
getTransaction,
getReimbursable,
};

export type {TransactionChanges};