Skip to content

Commit fc4297d

Browse files
committed
better function name and check for isExpenseReport too
1 parent 292f358 commit fc4297d

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/components/MoneyRequestHeader.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction,
8686
if (ReportUtils.isPaidGroupPolicyExpenseReport(moneyRequestReport)) {
8787
// If it's a paid policy expense report, only allow deleting the request if it's in draft state or instantly submitted state or the user is the policy admin
8888
canDeleteRequest =
89-
canDeleteRequest && (ReportUtils.isDraftExpenseReport(moneyRequestReport) || ReportUtils.isInstantSubmittedState(moneyRequestReport) || PolicyUtils.isPolicyAdmin(policy));
89+
canDeleteRequest &&
90+
(ReportUtils.isDraftExpenseReport(moneyRequestReport) || ReportUtils.isExpenseReportWithInstantSubmittedState(moneyRequestReport) || PolicyUtils.isPolicyAdmin(policy));
9091
}
9192

9293
const changeMoneyRequestStatus = () => {

src/libs/ReportUtils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -958,9 +958,9 @@ function isProcessingReport(report: OnyxEntry<Report> | EmptyObject): boolean {
958958
/**
959959
* Returns true if the policy has `instant` reporting frequency and if the report is still being processed (i.e. submitted state)
960960
*/
961-
function isInstantSubmittedState(report: OnyxEntry<Report> | EmptyObject): boolean {
961+
function isExpenseReportWithInstantSubmittedState(report: OnyxEntry<Report> | EmptyObject): boolean {
962962
const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`] ?? null;
963-
return isProcessingReport(report) && PolicyUtils.isInstantSubmitEnabled(policy);
963+
return isExpenseReport(report) && isProcessingReport(report) && PolicyUtils.isInstantSubmitEnabled(policy);
964964
}
965965

966966
/**
@@ -1273,7 +1273,7 @@ function canDeleteReportAction(reportAction: OnyxEntry<ReportAction>, reportID:
12731273
if (isActionOwner) {
12741274
if (!isEmptyObject(report) && isPaidGroupPolicyExpenseReport(report)) {
12751275
// If it's a paid policy expense report, only allow deleting the request if it's a draft or is instantly submitted or the user is the policy admin
1276-
return isDraftExpenseReport(report) || isInstantSubmittedState(report) || PolicyUtils.isPolicyAdmin(policy);
1276+
return isDraftExpenseReport(report) || isExpenseReportWithInstantSubmittedState(report) || PolicyUtils.isPolicyAdmin(policy);
12771277
}
12781278
return true;
12791279
}
@@ -4264,7 +4264,7 @@ function canRequestMoney(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>, o
42644264
if (isMoneyRequestReport(report)) {
42654265
const isOwnExpenseReport = isExpenseReport(report) && isOwnPolicyExpenseChat;
42664266
if (isOwnExpenseReport && PolicyUtils.isPaidGroupPolicy(policy)) {
4267-
return isDraftExpenseReport(report) || isInstantSubmittedState(report);
4267+
return isDraftExpenseReport(report) || isExpenseReportWithInstantSubmittedState(report);
42684268
}
42694269

42704270
return (isOwnExpenseReport || isIOUReport(report)) && !isReportApproved(report) && !isSettled(report?.reportID);
@@ -5066,7 +5066,7 @@ export {
50665066
isPublicAnnounceRoom,
50675067
isConciergeChatReport,
50685068
isProcessingReport,
5069-
isInstantSubmittedState,
5069+
isExpenseReportWithInstantSubmittedState,
50705070
isCurrentUserTheOnlyParticipant,
50715071
hasAutomatedExpensifyAccountIDs,
50725072
hasExpensifyGuidesEmails,

src/libs/actions/IOU.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ function getMoneyRequestInformation(
805805
needsToBeManuallySubmitted = isFromPaidPolicy && !policy?.harvesting?.enabled;
806806

807807
// If the linked expense report on paid policy is not draft and not instantly submitted, we need to create a new draft expense report
808-
if (iouReport && isFromPaidPolicy && !ReportUtils.isDraftExpenseReport(iouReport) && !ReportUtils.isInstantSubmittedState(iouReport)) {
808+
if (iouReport && isFromPaidPolicy && !ReportUtils.isDraftExpenseReport(iouReport) && !ReportUtils.isExpenseReportWithInstantSubmittedState(iouReport)) {
809809
iouReport = null;
810810
}
811811
}

0 commit comments

Comments
 (0)