Skip to content

Commit ba5065b

Browse files
authored
Merge pull request #74010 from huult/73312-fix-create-report-unresponsive-after-workspace-deleted
fix create report becomes unresponsive after deleting workspace
2 parents f0649e5 + 935aa63 commit ba5065b

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/components/ReportActionItem/MoneyRequestView.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
3636
import {getRateFromMerchant} from '@libs/MergeTransactionUtils';
3737
import {hasEnabledOptions} from '@libs/OptionsListUtils';
3838
import Parser from '@libs/Parser';
39-
import {getLengthOfTag, getTagLists, hasDependentTags as hasDependentTagsPolicyUtils, isTaxTrackingEnabled} from '@libs/PolicyUtils';
39+
import {canSubmitPerDiemExpenseFromWorkspace, getLengthOfTag, getTagLists, hasDependentTags as hasDependentTagsPolicyUtils, isTaxTrackingEnabled} from '@libs/PolicyUtils';
4040
import {getOriginalMessage, isMoneyRequestAction} from '@libs/ReportActionsUtils';
4141
import {isSplitAction} from '@libs/ReportSecondaryActionUtils';
4242
import type {TransactionDetails} from '@libs/ReportUtils';
@@ -261,8 +261,11 @@ function MoneyRequestView({
261261
const canEditDistance = isEditable && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DISTANCE, undefined, isChatReportArchived);
262262
const canEditDistanceRate = isEditable && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DISTANCE_RATE, undefined, isChatReportArchived);
263263
const canEditReport = useMemo(
264-
() => isEditable && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.REPORT, undefined, isChatReportArchived, outstandingReportsByPolicyID),
265-
[isEditable, parentReportAction, isChatReportArchived, outstandingReportsByPolicyID],
264+
() =>
265+
isEditable &&
266+
canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.REPORT, undefined, isChatReportArchived, outstandingReportsByPolicyID) &&
267+
(!isPerDiemRequest || canSubmitPerDiemExpenseFromWorkspace(policy)),
268+
[isEditable, parentReportAction, isChatReportArchived, outstandingReportsByPolicyID, isPerDiemRequest, policy],
266269
);
267270

268271
// A flag for verifying that the current report is a sub-report of a expense chat
@@ -288,7 +291,6 @@ function MoneyRequestView({
288291
policy?.defaultReimbursable !== undefined && !!(updatedTransaction?.reimbursable ?? transactionReimbursable) !== policy.defaultReimbursable;
289292
const shouldShowReimbursable =
290293
(isPolicyExpenseChat || isExpenseUnreported) &&
291-
!!policyForMovingExpensesID &&
292294
(policy?.disabledFields?.reimbursable !== true || isCurrentTransactionReimbursableDifferentFromPolicyDefault) &&
293295
!isCardTransaction &&
294296
!isInvoice;

src/pages/iou/request/step/IOURequestStepReport.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) {
220220
isUnreported={isUnreported}
221221
shouldShowNotFoundPage={shouldShowNotFoundPage}
222222
isPerDiemRequest={transaction ? isPerDiemRequest(transaction) : false}
223-
createReport={action === CONST.IOU.ACTION.EDIT ? createReport : undefined}
223+
createReport={action === CONST.IOU.ACTION.EDIT && (policyForMovingExpensesID || shouldSelectPolicy) ? createReport : undefined}
224224
/>
225225
</>
226226
);

0 commit comments

Comments
 (0)