Skip to content

Commit 397f933

Browse files
Merge pull request Expensify#77963 from Burhan-Rashid/fix/76205
fix: report field not disabled for per diem requests with no outstanding reports
2 parents 0c48eec + 466ad16 commit 397f933

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/components/MoneyRequestConfirmationListFooter.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import {getDestinationForDisplay, getSubratesFields, getSubratesForDisplay, getT
2222
import {canSendInvoice, getPerDiemCustomUnit} from '@libs/PolicyUtils';
2323
import type {ThumbnailAndImageURI} from '@libs/ReceiptUtils';
2424
import {getThumbnailAndImageURIs} from '@libs/ReceiptUtils';
25-
import {generateReportID, getDefaultWorkspaceAvatar, getOutstandingReportsForUser, getReportName, isArchivedReport, isMoneyRequestReport, isReportOutstanding} from '@libs/ReportUtils';
25+
import {computeReportName} from '@libs/ReportNameUtils';
26+
import {generateReportID, getDefaultWorkspaceAvatar, getOutstandingReportsForUser, isArchivedReport, isMoneyRequestReport, isReportOutstanding} from '@libs/ReportUtils';
2627
import {getTagVisibility, hasEnabledTags} from '@libs/TagsOptionsListUtils';
2728
import {
2829
getTagForDisplay,
@@ -321,7 +322,6 @@ function MoneyRequestConfirmationListFooter({
321322
*/
322323
const transactionReport = transaction?.reportID ? Object.values(allReports ?? {}).find((report) => report?.reportID === transaction.reportID) : undefined;
323324
const policyID = selectedParticipants?.at(0)?.policyID;
324-
const selectedPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`];
325325
const shouldUseTransactionReport = (!!transactionReport && isReportOutstanding(transactionReport, policyID, undefined, false)) || isUnreported;
326326

327327
const ownerAccountID = selectedParticipants?.at(0)?.ownerAccountID;
@@ -346,19 +346,19 @@ function MoneyRequestConfirmationListFooter({
346346
}, [allReports, shouldUseTransactionReport, transaction?.reportID, outstandingReportID]);
347347

348348
const reportName = useMemo(() => {
349-
const name = getReportName(selectedReport, selectedPolicy);
349+
const name = computeReportName(selectedReport, allReports, allPolicies);
350350
if (!name) {
351351
return isUnreported ? translate('common.none') : translate('iou.newReport');
352352
}
353353
return name;
354-
}, [isUnreported, selectedReport, selectedPolicy, translate]);
354+
}, [isUnreported, selectedReport, allReports, allPolicies, translate]);
355355

356356
const shouldReportBeEditableFromFAB = isUnreported ? allOutstandingReports.length >= 1 : allOutstandingReports.length > 1;
357357

358358
// When creating an expense in an individual report, the report field becomes read-only
359359
// since the destination is already determined and there's no need to show a selectable list.
360-
const shouldReportBeEditable = (isFromGlobalCreate ? shouldReportBeEditableFromFAB : availableOutstandingReports.length > 1) && !isMoneyRequestReport(reportID, allReports);
361-
360+
const shouldReportBeEditable =
361+
(isFromGlobalCreate && !isPerDiemRequest ? shouldReportBeEditableFromFAB : availableOutstandingReports.length > 1) && !isMoneyRequestReport(reportID, allReports);
362362
const taxRates = policy?.taxRates ?? null;
363363
// In Send Money and Split Bill with Scan flow, we don't allow the Merchant or Date to be edited. For distance requests, don't show the merchant as there's already another "Distance" menu item
364364
const shouldShowDate = shouldShowSmartScanFields || isDistanceRequest;

0 commit comments

Comments
 (0)