diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 51c64650477a..d47084bc7aba 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -55,11 +55,22 @@ type MoneyReportHeaderProps = { /** Whether we should display the header as in narrow layout */ shouldUseNarrowLayout?: boolean; + /** The accountID of the current user */ + currentUserAccountID: number; + /** Method to trigger when pressing close button of the header */ onBackButtonPress: () => void; }; -function MoneyReportHeader({policy, report: moneyRequestReport, transactionThreadReportID, reportActions, shouldUseNarrowLayout = false, onBackButtonPress}: MoneyReportHeaderProps) { +function MoneyReportHeader({ + policy, + report: moneyRequestReport, + transactionThreadReportID, + reportActions, + shouldUseNarrowLayout = false, + onBackButtonPress, + currentUserAccountID, +}: MoneyReportHeaderProps) { const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReport.chatReportID}`); const [nextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${moneyRequestReport.reportID}`); const [transactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`); @@ -118,7 +129,9 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea const shouldShowSubmitButton = isDraft && reimbursableSpend !== 0 && !allHavePendingRTERViolation; - const shouldShowExportIntegrationButton = !shouldShowPayButton && !shouldShowSubmitButton && connectedIntegration && !!policy; + const isManager = currentUserAccountID === moneyRequestReport?.managerID; + const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN; + const shouldShowExportIntegrationButton = !shouldShowPayButton && !shouldShowSubmitButton && connectedIntegration && (isManager || isAdmin); const shouldShowSettlementButton = (shouldShowPayButton || shouldShowApproveButton) && !allHavePendingRTERViolation && !shouldShowExportIntegrationButton; diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index 053f2774279e..b9d824375c42 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -37,7 +37,7 @@ import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type {Policy, Report, ReportAction, Transaction, TransactionViolations, UserWallet} from '@src/types/onyx'; +import type {Policy, Report, ReportAction, Session, Transaction, TransactionViolations, UserWallet} from '@src/types/onyx'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; import ExportWithDropdownMenu from './ExportWithDropdownMenu'; import type {PendingMessageProps} from './MoneyRequestPreview/types'; @@ -47,6 +47,8 @@ type ReportPreviewOnyxProps = { /** The policy tied to the expense report */ policy: OnyxEntry; + session: OnyxEntry; + /** ChatReport associated with iouReport */ chatReport: OnyxEntry; @@ -96,6 +98,7 @@ function ReportPreview({ iouReport, policy, iouReportID, + session, policyID, chatReportID, chatReport, @@ -115,6 +118,7 @@ function ReportPreview({ const {canUseViolations} = usePermissions(); const {isOffline} = useNetwork(); + const currentUserAccountID = session?.accountID; const {hasMissingSmartscanFields, areAllRequestsBeingSmartScanned, hasOnlyTransactionsWithPendingRoutes, hasNonReimbursableTransactions} = useMemo( () => ({ hasMissingSmartscanFields: ReportUtils.hasMissingSmartscanFields(iouReportID), @@ -341,7 +345,9 @@ function ReportPreview({ */ const connectedIntegration = PolicyUtils.getConnectedIntegration(policy); - const shouldShowExportIntegrationButton = !shouldShowPayButton && !shouldShowSubmitButton && connectedIntegration; + const isManager = currentUserAccountID === iouReport?.managerID; + const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN; + const shouldShowExportIntegrationButton = !shouldShowPayButton && !shouldShowSubmitButton && connectedIntegration && (isManager || isAdmin); return ( ({ userWallet: { key: ONYXKEYS.USER_WALLET, }, + session: { + key: ONYXKEYS.SESSION, + }, })(ReportPreview);