Skip to content

Commit

Permalink
Merge pull request #47720 from dominictb/fix/46954-write-action
Browse files Browse the repository at this point in the history
fix: update readonly check in canUserPerformWriteAction
  • Loading branch information
pecanoro authored Aug 22, 2024
2 parents 8a40e71 + 9f34483 commit bf5d743
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function MoneyRequestView({

// Flags for allowing or disallowing editing an expense
// Used for non-restricted fields such as: description, category, tag, billable, etc...
const canUserPerformWriteAction = !!ReportUtils.canUserPerformWriteAction(report);
const canUserPerformWriteAction = !!ReportUtils.canUserPerformWriteAction(report) && !readonly;
const canEdit = ReportActionsUtils.isMoneyRequestAction(parentReportAction) && ReportUtils.canEditMoneyRequest(parentReportAction, transaction) && canUserPerformWriteAction;

const canEditTaxFields = canEdit && !isDistanceRequest;
Expand Down Expand Up @@ -344,8 +344,8 @@ function MoneyRequestView({
<MenuItemWithTopDescription
description={translate('common.distance')}
title={distanceToDisplay}
interactive={canEditDistance && !readonly}
shouldShowRightIcon={canEditDistance && !readonly}
interactive={canEditDistance}
shouldShowRightIcon={canEditDistance}
titleStyle={styles.flex1}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1'))
Expand All @@ -370,8 +370,8 @@ function MoneyRequestView({
<MenuItemWithTopDescription
description={translate('common.distance')}
title={transactionMerchant}
interactive={canEditDistance && !readonly}
shouldShowRightIcon={canEditDistance && !readonly}
interactive={canEditDistance}
shouldShowRightIcon={canEditDistance}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1'))}
/>
Expand Down Expand Up @@ -428,8 +428,8 @@ function MoneyRequestView({
<MenuItemWithTopDescription
description={name ?? translate('common.tag')}
title={TransactionUtils.getTagForDisplay(updatedTransaction ?? transaction, index)}
interactive={canEdit && !readonly}
shouldShowRightIcon={canEdit && !readonly}
interactive={canEdit}
shouldShowRightIcon={canEdit}
titleStyle={styles.flex1}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.EDIT, iouType, orderWeight, transaction?.transactionID ?? '', report?.reportID ?? '-1'))
Expand Down Expand Up @@ -501,7 +501,7 @@ function MoneyRequestView({
{shouldShowReceiptEmptyState && (
<ReceiptEmptyState
hasError={hasErrors}
disabled={!canEditReceipt || readonly}
disabled={!canEditReceipt}
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(
Expand All @@ -524,8 +524,8 @@ function MoneyRequestView({
titleIcon={Expensicons.Checkmark}
description={amountDescription}
titleStyle={styles.textHeadlineH2}
interactive={canEditAmount && !readonly}
shouldShowRightIcon={canEditAmount && !readonly}
interactive={canEditAmount}
shouldShowRightIcon={canEditAmount}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1'))
}
Expand All @@ -538,8 +538,8 @@ function MoneyRequestView({
description={translate('common.description')}
shouldParseTitle
title={updatedTransactionDescription ?? transactionDescription}
interactive={canEdit && !readonly}
shouldShowRightIcon={canEdit && !readonly}
interactive={canEdit}
shouldShowRightIcon={canEdit}
titleStyle={styles.flex1}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1'))
Expand All @@ -557,8 +557,8 @@ function MoneyRequestView({
<MenuItemWithTopDescription
description={translate('common.merchant')}
title={updatedTransaction?.modifiedMerchant ?? merchantTitle}
interactive={canEditMerchant && !readonly}
shouldShowRightIcon={canEditMerchant && !readonly}
interactive={canEditMerchant}
shouldShowRightIcon={canEditMerchant}
titleStyle={styles.flex1}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1'))
Expand All @@ -574,8 +574,8 @@ function MoneyRequestView({
<MenuItemWithTopDescription
description={translate('common.date')}
title={transactionDate}
interactive={canEditDate && !readonly}
shouldShowRightIcon={canEditDate && !readonly}
interactive={canEditDate}
shouldShowRightIcon={canEditDate}
titleStyle={styles.flex1}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1' ?? '-1'))
Expand All @@ -589,8 +589,8 @@ function MoneyRequestView({
<MenuItemWithTopDescription
description={translate('common.category')}
title={updatedTransaction?.category ?? transactionCategory}
interactive={canEdit && !readonly}
shouldShowRightIcon={canEdit && !readonly}
interactive={canEdit}
shouldShowRightIcon={canEdit}
titleStyle={styles.flex1}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1'))
Expand All @@ -616,8 +616,8 @@ function MoneyRequestView({
<MenuItemWithTopDescription
title={taxRateTitle ?? ''}
description={taxRatesDescription}
interactive={canEditTaxFields && !readonly}
shouldShowRightIcon={canEditTaxFields && !readonly}
interactive={canEditTaxFields}
shouldShowRightIcon={canEditTaxFields}
titleStyle={styles.flex1}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report?.reportID ?? '-1'))
Expand All @@ -632,8 +632,8 @@ function MoneyRequestView({
<MenuItemWithTopDescription
title={formattedTaxAmount ? formattedTaxAmount.toString() : ''}
description={translate('iou.taxAmount')}
interactive={canEditTaxFields && !readonly}
shouldShowRightIcon={canEditTaxFields && !readonly}
interactive={canEditTaxFields}
shouldShowRightIcon={canEditTaxFields}
titleStyle={styles.flex1}
onPress={() =>
Navigation.navigate(
Expand Down Expand Up @@ -671,7 +671,7 @@ function MoneyRequestView({
accessibilityLabel={translate('common.billable')}
isOn={updatedTransaction?.billable ?? !!transactionBillable}
onToggle={saveBillable}
disabled={!canEdit || readonly}
disabled={!canEdit}
/>
</View>
)}
Expand Down

0 comments on commit bf5d743

Please sign in to comment.