[HOLD Web-E #51649] Add monthly spend limit per member for travel invoicing#86398
[HOLD Web-E #51649] Add monthly spend limit per member for travel invoicing#86398allgandalf wants to merge 9 commits intoExpensify:mainfrom
Conversation
|
Hey, I noticed you changed If you want to automatically generate translations for other locales, an Expensify employee will have to:
Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running: npx ts-node ./scripts/generateTranslations.ts --helpTypically, you'd want to translate only what you changed by running |
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
| }; | ||
|
|
||
| const handleSubmit = ({limit}: {limit: string}) => { | ||
| const newLimitInCents = convertToBackendAmount(parseFloat(limit)); |
There was a problem hiding this comment.
❌ CONSISTENCY-6 (docs)
parseFloat(limit) will return NaN when limit is an empty string or non-numeric, and convertToBackendAmount(NaN) produces NaN which would then be sent to the API. The analogous WorkspaceEditCardLimitPage.tsx passes a validate callback to FormProvider (using getFieldRequiredErrors) to prevent submission of empty or invalid values. This page is missing that validation.
Add a validate prop to FormProvider to guard against empty or invalid input, similar to the existing card limit page:
const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.EDIT_TRAVEL_INVOICING_MONTHLY_LIMIT_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.EDIT_TRAVEL_INVOICING_MONTHLY_LIMIT_FORM> => {
return getFieldRequiredErrors(values, [INPUT_IDS.LIMIT], translate);
};
// Then pass it to FormProvider:
<FormProvider
...
validate={validate}
>Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 066387ca12
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| }; | ||
|
|
||
| const handleSubmit = ({limit}: {limit: string}) => { | ||
| const newLimitInCents = convertToBackendAmount(parseFloat(limit)); |
There was a problem hiding this comment.
Guard monthly limit submit against empty input
handleSubmit converts the form value with convertToBackendAmount(parseFloat(limit)) without validating that limit is numeric. This form component allows an empty string, so clearing the amount and pressing Save produces NaN; the optimistic Onyx merge then writes monthlySpendLimitPerUser: NaN and the API call is sent with an invalid value, which can surface as a broken display/value in the Travel Invoicing section. Add a non-empty/numeric validation check before calling submitLimit.
Useful? React with 👍 / 👎.
Explanation of Change
Adds UI for configuring per-user monthly spend limit on travel invoicing cards (#85490).
monthlySpendLimitPerUserfield onExpensifyCardSettingsBasetypeWorkspaceTravelInvoicingSection(next to settlement frequency)ConfirmModalwhen admin lowers the limit below current valueDeployment order: Auth #20670 → Web-E #51649 → this PR
Fixed Issues
$ #85490
PROPOSAL: #85490 (comment)
Tests
Offline tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari