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
15 changes: 8 additions & 7 deletions src/components/FloatingCameraButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useMemo} from 'react';
import React, {useCallback, useMemo} from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useTheme from '@hooks/useTheme';
Expand Down Expand Up @@ -34,16 +34,17 @@ function FloatingCameraButton() {
const [allTransactionDrafts] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {canBeMissing: true});
const reportID = useMemo(() => generateReportID(), []);

const [policyChatForActivePolicy] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {
canBeMissing: true,
selector: (reports) => {
const policyChatForActivePolicySelector = useCallback(
(reports: OnyxCollection<OnyxTypes.Report>) => {
if (isEmptyObject(activePolicy) || !activePolicy?.isPolicyExpenseChatEnabled) {
return undefined;
}
const policyChatsForActivePolicy = getWorkspaceChats(activePolicyID, [session?.accountID ?? CONST.DEFAULT_NUMBER_ID], reports);
return policyChatsForActivePolicy.at(0);
},
});
[activePolicy, activePolicyID, session?.accountID],
);
const [policyChatForActivePolicy] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true, selector: policyChatForActivePolicySelector}, [policyChatForActivePolicySelector]);

const onPress = () => {
interceptAnonymousUser(() => {
Expand All @@ -53,7 +54,7 @@ function FloatingCameraButton() {
}

const quickActionReportID = policyChatForActivePolicy?.reportID ?? reportID;
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, quickActionReportID, CONST.IOU.REQUEST_TYPE.SCAN, true, undefined, allTransactionDrafts);
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, quickActionReportID, CONST.IOU.REQUEST_TYPE.SCAN, !!policyChatForActivePolicy?.reportID, undefined, allTransactionDrafts);
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1886,7 +1886,7 @@ function shouldEnableNegative(report: OnyxEntry<Report>, policy?: OnyxEntry<Poli
const isSelfDMReport = isSelfDMOrSelfDMThread(report);

return (
(isExpenseReport(report) || isGroupPolicy(policy?.type ?? '') || isSelfDMReport || iouType === CONST.IOU.TYPE.CREATE) &&
(isExpenseReport(report) || isGroupPolicy(policy?.type ?? '') || isSelfDMReport || iouType === CONST.IOU.TYPE.CREATE || iouType === CONST.IOU.TYPE.SUBMIT) &&
iouType !== CONST.IOU.TYPE.SPLIT &&
iouType !== CONST.IOU.TYPE.INVOICE
);
Expand Down
14 changes: 13 additions & 1 deletion src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,18 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref
});
}, [shouldRedirectToExpensifyClassic, allTransactionDrafts, reportID]);

const startQuickScan = useCallback(() => {
interceptAnonymousUser(() => {
if (policyChatForActivePolicy?.policyID && shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyChatForActivePolicy.policyID));
return;
}

const quickActionReportID = policyChatForActivePolicy?.reportID ?? reportID;
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, quickActionReportID, CONST.IOU.REQUEST_TYPE.SCAN, true, undefined, allTransactionDrafts);
});
}, [policyChatForActivePolicy?.policyID, policyChatForActivePolicy?.reportID, reportID, allTransactionDrafts]);

/**
* Check if LHN status changed from active to inactive.
* Used to close already opened FAB menu when open any other pages (i.e. Press Command + K on web).
Expand Down Expand Up @@ -624,7 +636,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref
<FloatingReceiptButton
accessibilityLabel={translate('sidebarScreen.fabScanReceiptExplained')}
role={CONST.ROLE.BUTTON}
onPress={startScan}
onPress={startQuickScan}
/>
)}
<FloatingActionButton
Expand Down
8 changes: 8 additions & 0 deletions src/pages/iou/request/IOURequestStartPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {useProductTrainingContext} from '@components/ProductTrainingContext';
import ScreenWrapper from '@components/ScreenWrapper';
import TabSelector from '@components/TabSelector/TabSelector';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useHandleBackButton from '@hooks/useHandleBackButton';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
Expand Down Expand Up @@ -194,6 +195,13 @@ function IOURequestStartPage({
},
);

const onBackButtonPress = () => {
navigateBack();
return true;
};

useHandleBackButton(onBackButtonPress);

return (
<AccessOrNotFoundWrapper
reportID={reportID}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/WorkspaceInitialPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
shouldDisplayHelpButton={shouldUseNarrowLayout}
/>

<ScrollView contentContainerStyle={[styles.flexColumn]}>
<ScrollView contentContainerStyle={[styles.flexColumn, styles.pb14]}>
<OfflineWithFeedback
pendingAction={policy?.pendingAction}
onClose={() => dismissError(policyID, policy?.pendingAction)}
Expand Down