diff --git a/src/components/SpendRules/SpendRulesSection.tsx b/src/components/SpendRules/SpendRulesSection.tsx index 6378179a01f5..9a2ac9ac433f 100644 --- a/src/components/SpendRules/SpendRulesSection.tsx +++ b/src/components/SpendRules/SpendRulesSection.tsx @@ -32,10 +32,9 @@ import ROUTES from '@src/ROUTES'; type SpendRulesSectionProps = { policyID: string; - canWriteRules: boolean; }; -function SpendRulesSection({policyID, canWriteRules}: SpendRulesSectionProps) { +function SpendRulesSection({policyID}: SpendRulesSectionProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); @@ -159,8 +158,7 @@ function SpendRulesSection({policyID, canWriteRules}: SpendRulesSectionProps) { accessibilityLabel={`${descriptionLabel}. ${blockLabel} ${defaultRuleTitle}`} sentryLabel={CONST.SENTRY_LABEL.WORKSPACE.RULES.SPEND_RULE_ITEM} onPress={showBuiltInProtectionModal} - shouldShowRightIcon={canWriteRules} - interactive={canWriteRules} + shouldShowRightIcon /> {isLoadingCardRules ? ( @@ -180,12 +178,11 @@ function SpendRulesSection({policyID, canWriteRules}: SpendRulesSectionProps) { pendingAction={rule.pendingAction} > Navigation.navigate(ROUTES.RULES_SPEND_EDIT.getRoute(policyID, rule.ruleID))} - interactive={canWriteRules} wrapperStyle={[styles.borderedContentCard, styles.mt2, styles.ph4, styles.pv4]} titleComponent={ @@ -221,7 +218,7 @@ function SpendRulesSection({policyID, canWriteRules}: SpendRulesSectionProps) { )) )} - {!isProduction && canWriteRules && ( + {!isProduction && ( {showTableControls && } - {canWriteCompanyCards && ( - {}} - shouldUseOptionIcon - customText={translate('common.more')} - options={secondaryActions} - isSplitButton={false} - wrapperStyle={shouldShowNarrowLayout ? styles.flex1 : styles.flexGrow0} - sentryLabel={CONST.SENTRY_LABEL.WORKSPACE.COMPANY_CARDS.MORE_DROPDOWN} - /> - )} + {}} + shouldUseOptionIcon + customText={translate('common.more')} + options={secondaryActions} + isSplitButton={false} + wrapperStyle={shouldShowNarrowLayout ? styles.flex1 : styles.flexGrow0} + sentryLabel={CONST.SENTRY_LABEL.WORKSPACE.COMPANY_CARDS.MORE_DROPDOWN} + /> )} - {!isLoading && canWriteCompanyCards && (isFeedConnectionBroken || hasFeedErrors) && ( + {!isLoading && (isFeedConnectionBroken || hasFeedErrors) && ( void; }; -function WorkspaceCompanyCardTableRow({ - item, - policyID, - CardFeedIcon, - shouldUseNarrowTableLayout, - rowIndex, - isAssigningCardDisabled, - canWriteCompanyCards, - onAssignCard, -}: WorkspaceCompanyCardTableRowProps) { +function WorkspaceCompanyCardTableRow({item, policyID, CardFeedIcon, shouldUseNarrowTableLayout, rowIndex, isAssigningCardDisabled, onAssignCard}: WorkspaceCompanyCardTableRowProps) { const theme = useTheme(); const styles = useThemeStyles(); const {isOffline} = useNetwork(); @@ -106,28 +94,20 @@ function WorkspaceCompanyCardTableRow({ ? {width: variables.cardAvatarWidth, height: variables.cardAvatarHeight} : {width: variables.cardAvatarWidthSmall, height: variables.cardAvatarHeightSmall}; - const canOpenCardDetails = !!assignedCard?.accountID && !!assignedCard?.fundID && assignedCard?.cardID !== undefined; - const canAssignCard = !isAssigned && canWriteCompanyCards && !isAssigningCardDisabled; - const canPressRow = canOpenCardDetails || canAssignCard; - const handleRowPress = () => { if (!assignedCard) { - if (!canAssignCard) { - return; - } onAssignCard(cardName, encryptedCardNumber); return; } - const {cardID, fundID} = assignedCard; - if (!canOpenCardDetails || cardID === undefined || !fundID) { + if (!assignedCard?.accountID || !assignedCard?.fundID) { return; } - const feedName = getCardFeedWithDomainID(assignedCard?.bank as CompanyCardFeed, fundID); + const feedName = getCardFeedWithDomainID(assignedCard?.bank as CompanyCardFeed, assignedCard.fundID); - return Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARD_DETAILS.getRoute(policyID, feedName as CompanyCardFeedWithDomainID, cardID.toString())); + return Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARD_DETAILS.getRoute(policyID, feedName as CompanyCardFeedWithDomainID, assignedCard.cardID.toString())); }; return ( @@ -135,7 +115,7 @@ function WorkspaceCompanyCardTableRow({ interactive rowIndex={rowIndex} isLoading={isDeleting} - disabled={isCardDeleted || !canPressRow} + disabled={isCardDeleted || isAssigningCardDisabled} skeletonReasonAttributes={reasonAttributes} sentryLabel={CONST.SENTRY_LABEL.WORKSPACE.COMPANY_CARDS.TABLE_ITEM} LoadingComponent={WorkspaceCompanyCardsTableSkeleton} @@ -195,7 +175,7 @@ function WorkspaceCompanyCardTableRow({ )} - {!isAssigned && canWriteCompanyCards && ( + {!isAssigned && (