Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: $0 doesn't save in the Receipt #54949

Merged
merged 7 commits into from
Feb 3, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/pages/workspace/rules/IndividualExpenseRulesSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type IndividualExpenseRulesMenuItem = {
};

function IndividualExpenseRulesSectionSubtitle({policy, translate, styles}: IndividualExpenseRulesSectionSubtitleProps) {
const policyID = policy?.id ?? '-1';
const policyID = `${policy?.id ?? CONST.DEFAULT_NUMBER_ID}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can't you just do:

Suggested change
const policyID = `${policy?.id ?? CONST.DEFAULT_NUMBER_ID}`;
const policyID = policy?.id;

Am i missing something ? this looks a bit hacky and doesn't explain the requirement

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@allgandalf policyID here is used to pass as a params to the getRoute functions below. We have a similar example here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nkdengineer can you raise a discussion in open source channel, this is highly disregarded approach i guess

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take a look here once

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it contains the same question and the link to the discussion, are we aligned with it in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @allgandalf, i updated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@allgandalf friendly bump here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed this comment, sorry


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);
}, [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);
}, [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
Loading