Skip to content

Commit

Permalink
Merge pull request #54949 from nkdengineer/fix/54290
Browse files Browse the repository at this point in the history
fix: $0 doesn't save in the Receipt
  • Loading branch information
danieldoglas authored Feb 3, 2025
2 parents a038781 + bd77cb7 commit 21a97d8
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/pages/workspace/rules/IndividualExpenseRulesSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import TextLink from '@components/TextLink';
import useLocalize from '@hooks/useLocalize';
import usePolicy from '@hooks/usePolicy';
import useThemeStyles from '@hooks/useThemeStyles';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import {openExternalLink} from '@libs/actions/Link';
import {setWorkspaceEReceiptsEnabled} from '@libs/actions/Policy/Policy';
import {convertToDisplayString} from '@libs/CurrencyUtils';
import Navigation from '@libs/Navigation/Navigation';
import type {ThemeStyles} from '@styles/index';
import * as Link from '@userActions/Link';
import * as PolicyActions from '@userActions/Policy/Policy';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ROUTES from '@src/ROUTES';
Expand All @@ -39,7 +39,7 @@ type IndividualExpenseRulesMenuItem = {
};

function IndividualExpenseRulesSectionSubtitle({policy, translate, styles}: IndividualExpenseRulesSectionSubtitleProps) {
const policyID = policy?.id ?? '-1';
const policyID = policy?.id;

const handleOnPressCategoriesLink = () => {
if (policy?.areCategoriesEnabled) {
Expand Down Expand Up @@ -88,27 +88,27 @@ function IndividualExpenseRulesSection({policyID}: IndividualExpenseRulesSection
const policyCurrency = policy?.outputCurrency ?? CONST.CURRENCY.USD;

const maxExpenseAmountNoReceiptText = useMemo(() => {
if (policy?.maxExpenseAmountNoReceipt === CONST.DISABLED_MAX_EXPENSE_VALUE || !policy?.maxExpenseAmountNoReceipt) {
if (policy?.maxExpenseAmountNoReceipt === CONST.DISABLED_MAX_EXPENSE_VALUE) {
return '';
}

return CurrencyUtils.convertToDisplayString(policy?.maxExpenseAmountNoReceipt, policyCurrency);
return convertToDisplayString(policy?.maxExpenseAmountNoReceipt, policyCurrency);
}, [policy?.maxExpenseAmountNoReceipt, policyCurrency]);

const maxExpenseAmountText = useMemo(() => {
if (policy?.maxExpenseAmount === CONST.DISABLED_MAX_EXPENSE_VALUE || !policy?.maxExpenseAmount) {
if (policy?.maxExpenseAmount === CONST.DISABLED_MAX_EXPENSE_VALUE) {
return '';
}

return CurrencyUtils.convertToDisplayString(policy?.maxExpenseAmount, policyCurrency);
return convertToDisplayString(policy?.maxExpenseAmount, policyCurrency);
}, [policy?.maxExpenseAmount, policyCurrency]);

const maxExpenseAgeText = useMemo(() => {
if (policy?.maxExpenseAge === CONST.DISABLED_MAX_EXPENSE_VALUE || !policy?.maxExpenseAge) {
if (policy?.maxExpenseAge === CONST.DISABLED_MAX_EXPENSE_VALUE) {
return '';
}

return translate('workspace.rules.individualExpenseRules.maxExpenseAgeDays', {count: policy?.maxExpenseAge});
return translate('workspace.rules.individualExpenseRules.maxExpenseAgeDays', {count: policy?.maxExpenseAge ?? 0});
}, [policy?.maxExpenseAge, translate]);

const billableModeText = translate(`workspace.rules.individualExpenseRules.${policy?.defaultBillable ? 'billable' : 'nonBillable'}`);
Expand Down Expand Up @@ -180,7 +180,7 @@ function IndividualExpenseRulesSection({policyID}: IndividualExpenseRulesSection
<Switch
isOn={areEReceiptsEnabled}
accessibilityLabel={translate('workspace.rules.individualExpenseRules.eReceipts')}
onToggle={() => PolicyActions.setWorkspaceEReceiptsEnabled(policyID, !areEReceiptsEnabled)}
onToggle={() => setWorkspaceEReceiptsEnabled(policyID, !areEReceiptsEnabled)}
disabled={policyCurrency !== CONST.CURRENCY.USD}
/>
</View>
Expand All @@ -189,7 +189,7 @@ function IndividualExpenseRulesSection({policyID}: IndividualExpenseRulesSection
<Text style={[styles.textLabel, styles.colorMuted]}>{translate('workspace.rules.individualExpenseRules.eReceiptsHint')}</Text>{' '}
<TextLink
style={[styles.textLabel, styles.link]}
onPress={() => Link.openExternalLink(CONST.DEEP_DIVE_ERECEIPTS)}
onPress={() => openExternalLink(CONST.DEEP_DIVE_ERECEIPTS)}
>
{translate('workspace.rules.individualExpenseRules.eReceiptsHintLink')}
</TextLink>
Expand Down

0 comments on commit 21a97d8

Please sign in to comment.