Skip to content

Commit

Permalink
Fix a crash when requesting money
Browse files Browse the repository at this point in the history
The `policy` can initially be undefined, which wasn't handled correctly.
  • Loading branch information
cubuspl42 committed Feb 14, 2024
1 parent e6c321f commit 4b73baf
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
const isMerchantEmpty = !iouMerchant || iouMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT;
const isMerchantRequired = isPolicyExpenseChat && !isScanRequest && shouldShowMerchant;

const isCategoryRequired = canUseViolations && Boolean(policy.requiresCategory);
const isTagRequired = canUseViolations && Boolean(policy.requiresTag);
const isCategoryRequired = canUseViolations && lodashGet(policy, 'requiresCategory', false);
const isTagRequired = canUseViolations && lodashGet(policy, 'requiresTag', false);

useEffect(() => {
if ((!isMerchantRequired && isMerchantEmpty) || !merchantError) {
Expand Down Expand Up @@ -761,7 +761,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
titleStyle={styles.flex1}
disabled={didConfirm}
interactive={!isReadOnly}
rightLabel={canUseViolations && Boolean(policy.requiresCategory) ? translate('common.required') : ''}
rightLabel={isCategoryRequired ? translate('common.required') : ''}
/>
),
shouldShow: shouldShowCategories,
Expand All @@ -783,7 +783,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
style={[styles.moneyRequestMenuItem]}
disabled={didConfirm}
interactive={!isReadOnly}
rightLabel={canUseViolations && lodashGet(policy, 'requiresTag', false) ? translate('common.required') : ''}
rightLabel={isTagRequired ? translate('common.required') : ''}
/>
),
shouldShow: shouldShowTags,
Expand Down

0 comments on commit 4b73baf

Please sign in to comment.