Skip to content

Commit f28ed6d

Browse files
author
Hayata Suenaga
authored
Merge pull request #42881 from s77rt/s77rt-display-delete-button
Disable tax deletion if connected to accounting
2 parents a229004 + 456003d commit f28ed6d

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/pages/workspace/taxes/WorkspaceEditTaxPage.tsx

+13-9
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function WorkspaceEditTaxPage({
4040
const {windowWidth} = useWindowDimensions();
4141
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);
4242
const canEdit = policy && PolicyUtils.canEditTaxRate(policy, taxID);
43+
const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy);
4344

4445
const toggleTaxRate = () => {
4546
if (!currentTaxRate) {
@@ -58,14 +59,17 @@ function WorkspaceEditTaxPage({
5859
};
5960

6061
const threeDotsMenuItems: ThreeDotsMenuItem[] = useMemo(
61-
() => [
62-
{
63-
icon: Expensicons.Trashcan,
64-
text: translate('common.delete'),
65-
onSelected: () => setIsDeleteModalVisible(true),
66-
},
67-
],
68-
[translate],
62+
() =>
63+
canEdit && !hasAccountingConnections
64+
? [
65+
{
66+
icon: Expensicons.Trashcan,
67+
text: translate('common.delete'),
68+
onSelected: () => setIsDeleteModalVisible(true),
69+
},
70+
]
71+
: [],
72+
[translate, canEdit, hasAccountingConnections],
6973
);
7074

7175
if (!currentTaxRate) {
@@ -86,7 +90,7 @@ function WorkspaceEditTaxPage({
8690
<HeaderWithBackButton
8791
title={currentTaxRate?.name}
8892
threeDotsMenuItems={threeDotsMenuItems}
89-
shouldShowThreeDotsButton={!!canEdit}
93+
shouldShowThreeDotsButton={threeDotsMenuItems.length > 0}
9094
threeDotsAnchorPosition={styles.threeDotsPopoverOffsetNoCloseButton(windowWidth)}
9195
/>
9296
<OfflineWithFeedback

0 commit comments

Comments
 (0)