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
7 changes: 6 additions & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,12 @@ const ROUTES = {

NEW_REPORT_WORKSPACE_SELECTION: {
route: 'new-report-workspace-selection',
getRoute: (isMovingExpenses?: boolean) => `new-report-workspace-selection${isMovingExpenses ? '?isMovingExpenses=true' : ''}` as const,
getRoute: (isMovingExpenses?: boolean, backTo?: string) => {
const baseRoute = `new-report-workspace-selection${isMovingExpenses ? '?isMovingExpenses=true' : ''}` as const;

// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
return getUrlWithBackToParam(baseRoute, backTo);
},
},
REPORT: 'r',
REPORT_WITH_ID: {
Expand Down
32 changes: 14 additions & 18 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {activePolicySelector} from '@selectors/Policy';
import {Str} from 'expensify-common';
import React, {useCallback, useContext, useEffect, useMemo, useState} from 'react';
import {View} from 'react-native';
Expand Down Expand Up @@ -70,7 +69,6 @@ import {
hasRoute as hasRouteTransactionUtils,
isCardTransaction as isCardTransactionTransactionUtils,
isDistanceRequest as isDistanceRequestTransactionUtils,
isExpenseUnreported as isExpenseUnreportedTransactionUtils,
isManualDistanceRequest as isManualDistanceRequestTransactionUtils,
isPerDiemRequest as isPerDiemRequestTransactionUtils,
isScanning,
Expand Down Expand Up @@ -131,6 +129,7 @@ function MoneyRequestView({
const {isBetaEnabled} = usePermissions();
const {translate, toLocaleDigit} = useLocalize();
const {getReportRHPActiveRoute} = useActiveRoute();
const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH, {canBeMissing: true});

const parentReportID = report?.parentReportID;
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${parentReportID}`];
Expand All @@ -148,16 +147,10 @@ function MoneyRequestView({
return originalMessage?.IOUTransactionID;
}, [parentReportAction]);
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(linkedTransactionID)}`, {canBeMissing: true});
const isExpenseUnreported = isExpenseUnreportedTransactionUtils(updatedTransaction ?? transaction);

const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`, {
canBeMissing: true,
selector: activePolicySelector,
});
// If the expense is unreported the policy should be the user's default policy, otherwise it should be the policy the expense was made for
const policy = isExpenseUnreported ? activePolicy : expensePolicy;
const policyID = isExpenseUnreported ? activePolicy?.id : report?.policyID;
const policy = expensePolicy;
const policyID = report?.policyID;

const allPolicyCategories = usePolicyCategories();
const policyCategories = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`];
Expand Down Expand Up @@ -250,9 +243,6 @@ function MoneyRequestView({
// A flag for verifying that the current report is a sub-report of a expense chat
// if the policy of the report is either Collect or Control, then this report must be tied to expense chat
const isPolicyExpenseChat = isReportInGroupPolicy(report);

const shouldShowPolicySpecificFields = isPolicyExpenseChat || isExpenseUnreported;

const policyTagLists = useMemo(() => getTagLists(policyTagList), [policyTagList]);

const iouType = useMemo(() => {
Expand All @@ -272,19 +262,19 @@ function MoneyRequestView({
// Flags for showing categories and tags
// transactionCategory can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const shouldShowCategory = (isPolicyExpenseChat && (categoryForDisplay || hasEnabledOptions(policyCategories ?? {}))) || isExpenseUnreported;
const shouldShowCategory = isPolicyExpenseChat && (categoryForDisplay || hasEnabledOptions(policyCategories ?? {}));
// transactionTag can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const shouldShowTag = shouldShowPolicySpecificFields && (transactionTag || hasEnabledTags(policyTagLists));
const shouldShowBillable = shouldShowPolicySpecificFields && (!!transactionBillable || !(policy?.disabledFields?.defaultBillable ?? true) || !!updatedTransaction?.billable);
const shouldShowTag = isPolicyExpenseChat && (transactionTag || hasEnabledTags(policyTagLists));
const shouldShowBillable = isPolicyExpenseChat && (!!transactionBillable || !(policy?.disabledFields?.defaultBillable ?? true) || !!updatedTransaction?.billable);
const isCurrentTransactionReimbursableDifferentFromPolicyDefault =
policy?.defaultReimbursable !== undefined && !!(updatedTransaction?.reimbursable ?? transactionReimbursable) !== policy.defaultReimbursable;
const shouldShowReimbursable =
isPolicyExpenseChat && (!policy?.disabledFields?.reimbursable || isCurrentTransactionReimbursableDifferentFromPolicyDefault) && !isCardTransaction && !isInvoice;
const canEditReimbursable = isEditable && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.REIMBURSABLE, undefined, isChatReportArchived);
const shouldShowAttendees = useMemo(() => shouldShowAttendeesTransactionUtils(iouType, policy), [iouType, policy]);

const shouldShowTax = isTaxTrackingEnabled(shouldShowPolicySpecificFields, policy, isDistanceRequest, isPerDiemRequest);
const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat, policy, isDistanceRequest, isPerDiemRequest);
const tripID = getTripIDFromTransactionParentReportID(parentReport?.parentReportID);
const shouldShowViewTripDetails = hasReservationList(transaction) && !!tripID;

Expand Down Expand Up @@ -857,7 +847,13 @@ function MoneyRequestView({
return;
}
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_REPORT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID, report.reportID, getReportRHPActiveRoute()),
ROUTES.MONEY_REQUEST_STEP_REPORT.getRoute(
CONST.IOU.ACTION.EDIT,
iouType,
transaction?.transactionID,
report.reportID,
getReportRHPActiveRoute() || lastVisitedPath,
),
);
}}
interactive={canEditReport}
Expand Down
24 changes: 22 additions & 2 deletions src/hooks/usePolicyForMovingExpenses.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import {activePolicySelector} from '@selectors/Policy';
import type {OnyxEntry} from 'react-native-onyx';
import {useSession} from '@components/OnyxListItemProvider';
import {isPaidGroupPolicy, isPolicyMemberWithoutPendingDelete} from '@libs/PolicyUtils';
import {getPolicyRole, isPaidGroupPolicy, isPolicyAdmin, isPolicyMemberWithoutPendingDelete, isPolicyUser} from '@libs/PolicyUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Policy} from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import useOnyx from './useOnyx';

// TODO: temporary util - if we don't have employeeList object we don't check for the pending delete
function checkForPendingDelete(login: string, policy: OnyxEntry<Policy>) {
if (isEmptyObject(policy?.employeeList)) {
return true;
}
return isPolicyMemberWithoutPendingDelete(login, policy);
}

function isPolicyMemberByRole(login: string, policy: OnyxEntry<Policy>) {
return isPolicyAdmin(policy, login) || isPolicyUser(policy, login) || getPolicyRole(policy, login) === CONST.POLICY.ROLE.AUDITOR;
Copy link
Copy Markdown
Member

@parasharrajat parasharrajat Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have isPolicyAuditor in PolicyUtils

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also update isPolicyAuditor method to use getPolicyRole as is using similiar logic inside.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parasharrajat yeaah, but it uses employees list 😅 so another one I cannot use. I don't want to change the util either, because getPolicyRole returns policy?.role when it exists and I guess this util is used to check other members for being auditor

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is reads policy first

(policy?.role ?? (currentUserLogin && policy?.employeeList?.[currentUserLogin]?.role)) === CONST.POLICY.ROLE.AUDITOR;

but it is fine.

}

function usePolicyForMovingExpenses() {
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
Expand All @@ -13,7 +29,11 @@ function usePolicyForMovingExpenses() {
});

const session = useSession();
const userPolicies = Object.values(allPolicies ?? {}).filter((policy) => isPolicyMemberWithoutPendingDelete(session?.email, policy) && isPaidGroupPolicy(policy));
const login = session?.email ?? '';
const userPolicies = Object.values(allPolicies ?? {}).filter(
(policy) =>
checkForPendingDelete(login, policy) && isPolicyMemberByRole(login, policy) && isPaidGroupPolicy(policy) && policy?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
);
const isMemberOfMoreThanOnePolicy = userPolicies.length > 1;

if (activePolicy) {
Expand Down
20 changes: 11 additions & 9 deletions src/hooks/useSelectedTransactionsActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function useSelectedTransactionsActions({
const {selectedTransactionIDs, clearSelectedTransactions} = useSearchContext();
const [allTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: false});
const [outstandingReportsByPolicyID] = useOnyx(ONYXKEYS.DERIVED.OUTSTANDING_REPORTS_BY_POLICY_ID, {canBeMissing: true});
const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH, {canBeMissing: true});

const [integrationsExportTemplates] = useOnyx(ONYXKEYS.NVP_INTEGRATION_SERVER_EXPORT_TEMPLATES, {canBeMissing: true});
const [csvExportLayouts] = useOnyx(ONYXKEYS.NVP_CSV_EXPORT_LAYOUTS, {canBeMissing: true});
Expand Down Expand Up @@ -252,7 +253,7 @@ function useSelectedTransactionsActions({
value: MOVE,
onSelected: () => {
const shouldTurnOffSelectionMode = allTransactionsLength - selectedTransactionIDs.length <= 1;
const route = ROUTES.MONEY_REQUEST_EDIT_REPORT.getRoute(CONST.IOU.ACTION.EDIT, iouType, report?.reportID, shouldTurnOffSelectionMode);
const route = ROUTES.MONEY_REQUEST_EDIT_REPORT.getRoute(CONST.IOU.ACTION.EDIT, iouType, report?.reportID, shouldTurnOffSelectionMode, lastVisitedPath);
Navigation.navigate(route);
},
});
Expand Down Expand Up @@ -304,20 +305,21 @@ function useSelectedTransactionsActions({
selectedTransactions,
translate,
isReportArchived,
policy,
reportActions,
clearSelectedTransactions,
onExportFailed,
allTransactionsLength,
integrationsExportTemplates,
csvExportLayouts,
isOffline,
onExportOffline,
onExportFailed,
beginExportWithTemplate,
outstandingReportsByPolicyID,
iouType,
lastVisitedPath,
session?.accountID,
showDeleteModal,
outstandingReportsByPolicyID,
policy,
beginExportWithTemplate,
isOffline,
onExportOffline,
csvExportLayouts,
integrationsExportTemplates,
]);

return {
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,7 @@ type ProfileNavigatorParamList = {
type NewReportWorkspaceSelectionNavigatorParamList = {
[SCREENS.NEW_REPORT_WORKSPACE_SELECTION.ROOT]: {
isMovingExpenses?: boolean;
backTo?: Routes;
};
};

Expand Down
8 changes: 0 additions & 8 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ function canUseLinkPreviews(): boolean {
return false;
}

/**
* Temporary check for Unreported Expense Project - change to true for testing
*/
function canUseUnreportedExpense(): boolean {
return false;
}

function isBetaEnabled(beta: Beta, betas: OnyxEntry<Beta[]>, betaConfiguration?: OnyxEntry<BetaConfiguration>): boolean {
const hasAllBetasEnabled = canUseAllBetas(betas);
const isFeatureEnabled = !!betas?.includes(beta);
Expand All @@ -38,5 +31,4 @@ function isBetaEnabled(beta: Beta, betas: OnyxEntry<Beta[]>, betaConfiguration?:
export default {
canUseLinkPreviews,
isBetaEnabled,
canUseUnreportedExpense,
};
6 changes: 0 additions & 6 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import {translateLocal} from '@libs/Localize';
import Log from '@libs/Log';
import {rand64, roundToTwoDecimalPlaces} from '@libs/NumberUtils';
import Permissions from '@libs/Permissions';
import {getPersonalDetailsByIDs} from '@libs/PersonalDetailsUtils';
import {
getCommaSeparatedTagNameWithSanitizedColons,
Expand Down Expand Up @@ -116,7 +115,7 @@

let allTransactions: OnyxCollection<Transaction> = {};

Onyx.connect({

Check warning on line 118 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -128,7 +127,7 @@
});

let allReports: OnyxCollection<Report> = {};
Onyx.connect({

Check warning on line 130 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -137,7 +136,7 @@
});

let allTransactionViolations: OnyxCollection<TransactionViolations> = {};
Onyx.connect({

Check warning on line 139 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => (allTransactionViolations = value),
Expand All @@ -145,7 +144,7 @@

let currentUserEmail = '';
let currentUserAccountID = -1;
Onyx.connect({

Check warning on line 147 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (val) => {
currentUserEmail = val?.email ?? '';
Expand Down Expand Up @@ -1959,12 +1958,7 @@
];
}

// Temporarily only for use in the Unreported Expense project
function isExpenseUnreported(transaction?: Transaction): transaction is UnreportedTransaction {
// TODO: added for development purposes, should be removed once the feature are fully implemented
if (!Permissions.canUseUnreportedExpense()) {
return false;
}
return transaction?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID;
}

Expand Down
27 changes: 17 additions & 10 deletions src/pages/NewReportWorkspaceSelectionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ type WorkspaceListItem = {
type NewReportWorkspaceSelectionPageProps = PlatformStackScreenProps<NewReportWorkspaceSelectionNavigatorParamList, typeof SCREENS.NEW_REPORT_WORKSPACE_SELECTION.ROOT>;

function NewReportWorkspaceSelectionPage({route}: NewReportWorkspaceSelectionPageProps) {
const {isMovingExpenses} = route.params ?? {};
const {isMovingExpenses, backTo} = route.params ?? {};
const {isOffline} = useNetwork();
const {selectedTransactions, clearSelectedTransactions} = useSearchContext();
const {selectedTransactions, selectedTransactionIDs, clearSelectedTransactions} = useSearchContext();
const styles = useThemeStyles();
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState('');
const {translate, localeCompare} = useLocalize();
Expand Down Expand Up @@ -87,34 +87,41 @@ function NewReportWorkspaceSelectionPage({route}: NewReportWorkspaceSelectionPag
}
const optimisticReportID = createNewReport(currentUserPersonalDetails, isASAPSubmitBetaEnabled, hasViolations, policyID);
const selectedTransactionsKeys = Object.keys(selectedTransactions);
if (isMovingExpenses && !!selectedTransactionsKeys.length) {

if (isMovingExpenses && (!!selectedTransactionsKeys.length || !!selectedTransactionIDs.length)) {
const reportNextStep = allReportNextSteps?.[`${ONYXKEYS.COLLECTION.NEXT_STEP}${optimisticReportID}`];
changeTransactionsReport(
selectedTransactionsKeys,
selectedTransactionsKeys.length ? selectedTransactionsKeys : selectedTransactionIDs,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are we doing here?

Copy link
Copy Markdown
Contributor Author

@koko57 koko57 Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we either use the keys or IDs. We either save the whole selectedTransactions objects or IDs only in the search context

optimisticReportID,
isASAPSubmitBetaEnabled,
currentUserPersonalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID,
currentUserPersonalDetails?.email ?? '',
policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`],
reportNextStep,
);
clearSelectedTransactions();
if (selectedTransactionIDs.length) {
clearSelectedTransactions(true);
} else if (selectedTransactionsKeys.length) {
clearSelectedTransactions();
}
Navigation.dismissModal();
Navigation.goBack(ROUTES.SEARCH_ROOT.getRoute({query: buildCannedSearchQuery()}));
Navigation.goBack(backTo ?? ROUTES.SEARCH_ROOT.getRoute({query: buildCannedSearchQuery()}));
return;
}
navigateToNewReport(optimisticReportID);
},
[
allReportNextSteps,
clearSelectedTransactions,
currentUserPersonalDetails,
isASAPSubmitBetaEnabled,
hasViolations,
selectedTransactions,
isMovingExpenses,
selectedTransactionIDs,
navigateToNewReport,
allReportNextSteps,
policies,
selectedTransactions,
hasViolations,
clearSelectedTransactions,
backTo,
],
);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Search/SearchTransactionsChangeReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ function SearchTransactionsChangeReport() {
const [allReportNextSteps] = useOnyx(ONYXKEYS.COLLECTION.NEXT_STEP, {canBeMissing: true});
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true});
const [allPolicyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}`, {canBeMissing: true});
const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true});
const {policyForMovingExpensesID, shouldSelectPolicy} = usePolicyForMovingExpenses();
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true});
const hasViolations = hasViolationsReportUtils(undefined, transactionViolations);
const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true});
const isASAPSubmitBetaEnabled = Permissions.isBetaEnabled(CONST.BETAS.ASAP_SUBMIT, allBetas);
const session = useSession();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
Expand Down
19 changes: 19 additions & 0 deletions src/pages/iou/request/step/IOURequestEditReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import React from 'react';
import {useSession} from '@components/OnyxListItemProvider';
import {useSearchContext} from '@components/Search/SearchContext';
import type {ListItem} from '@components/SelectionListWithSections/types';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useOnyx from '@hooks/useOnyx';
import usePolicyForMovingExpenses from '@hooks/usePolicyForMovingExpenses';
import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
import {changeTransactionsReport} from '@libs/actions/Transaction';
import Navigation from '@libs/Navigation/Navigation';
import Permissions from '@libs/Permissions';
import {hasViolations as hasViolationsReportUtils} from '@libs/ReportUtils';
import {createNewReport} from '@userActions/Report';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import IOURequestEditReportCommon from './IOURequestEditReportCommon';
import withWritableReportOrNotFound from './withWritableReportOrNotFound';
Expand All @@ -33,6 +38,10 @@ function IOURequestEditReport({route}: IOURequestEditReportProps) {
const session = useSession();
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true});
const [allPolicyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}`, {canBeMissing: true});
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const {policyForMovingExpensesID, shouldSelectPolicy} = usePolicyForMovingExpenses();
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true});
const hasViolations = hasViolationsReportUtils(undefined, transactionViolations);

const selectReport = (item: TransactionGroupListItem) => {
if (selectedTransactionIDs.length === 0 || item.value === reportID) {
Expand Down Expand Up @@ -67,6 +76,15 @@ function IOURequestEditReport({route}: IOURequestEditReportProps) {
Navigation.dismissModal();
};

const createReport = () => {
if (shouldSelectPolicy) {
Navigation.navigate(ROUTES.NEW_REPORT_WORKSPACE_SELECTION.getRoute(true, backTo));
return;
}
const createdReportID = createNewReport(currentUserPersonalDetails, hasViolations, isASAPSubmitBetaEnabled, policyForMovingExpensesID);
selectReport({value: createdReportID});
};

return (
<IOURequestEditReportCommon
backTo={backTo}
Expand All @@ -75,6 +93,7 @@ function IOURequestEditReport({route}: IOURequestEditReportProps) {
selectReport={selectReport}
removeFromReport={removeFromReport}
isEditing={action === CONST.IOU.ACTION.EDIT}
createReport={createReport}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function IOURequestEditReportCommon({
const headerMessage = useMemo(() => (searchValue && !reportOptions.length ? translate('common.noResultsFound') : ''), [searchValue, reportOptions, translate]);

const createReportOption = useMemo(() => {
if (!createReport || isUnreported === false) {
if (!createReport || isUnreported) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!createReport || isUnreported) {
if (!createReport || !isUnreported) {

Shouldn't this be like that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're hoding it for now for unreported

return undefined;
}

Expand Down
Loading
Loading