-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Due for payment 2025-02-13] [$250] $0 doesn't save in the Receipt required amount field in Workspaces #54290
Comments
Triggered auto assignment to @stephanieelliott ( |
Edited by proposal-police: This proposal was edited at 2024-12-18 13:05:49 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.$0 doesn't save in the Receipt required amount field in Workspaces What is the root cause of that problem?We are displaying empty string if the maxExpenseAmountNoReceipt is falsy here App/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx Lines 91 to 92 in 4b0f250
and also here
but 0 is falsy What changes do you think we should make in order to solve the problem?We should check for the type instead for both cases
Note: I have seen similar problems with maxExpenseAmount here and here and for maxExpenseAge here and here policyCategory.maxExpenseAmount here and here. The BE allows the values to be set to 0 value but we are displaying empty string so we can apply similar fix as above for these cases too. But if this cases are different from maxExpenseAmountNoReceipt and we don't want to allow zero value then we should update the BE to disallow it and also update our FE code to disallow it and show error on validate but in the scope of this issue on maxExpenseAmountNoReceipt we are sure 0 is allowed so we can apply the above fix 👍 What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?We can test IndividualExpenseRulesSection and PolicyRulesPage by setting maxExpenseAmountNoReceipt to 0 and asserting 0 is displayed not empty string. What alternative solutions did you explore? (Optional)optionally use a check of |
Edited by proposal-police: This proposal was edited at 2025-01-02 04:46:31 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.$0 doesn't save in the Receipt required amount field in Workspaces What is the root cause of that problem?We are checking if App/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx Lines 91 to 93 in d5aa1bd
App/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx Lines 99 to 101 in d5aa1bd
App/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx Lines 107 to 109 in d5aa1bd
App/src/pages/workspace/rules/RulesReceiptRequiredAmountPage.tsx Lines 37 to 40 in 286b679
App/src/pages/workspace/rules/RulesMaxExpenseAmountPage.tsx Lines 37 to 40 in 286b679
What changes do you think we should make in order to solve the problem?So we shouldn’t accept a 0 value when the user inputs it. We should validate the form and return an error like ‘Invalid amount’ if the value is 0. Something like this: Add this function: const validate = useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.RULES_REQUIRED_RECEIPT_AMOUNT_FORM>) => {
const errors: FormInputErrors<typeof ONYXKEYS.FORMS.RULES_REQUIRED_RECEIPT_AMOUNT_FORM> = {};
const maxExpenseAmountNoReceipt = values[INPUT_IDS.MAX_EXPENSE_AMOUNT_NO_RECEIPT];
if (maxExpenseAmountNoReceipt === '0') {
errors.maxExpenseAmountNoReceipt = translate('workspace.rules.individualExpenseRules.errors.invalidAmount');
}
return errors;
},
[translate],
);
update <FormProvider
style={[styles.flexGrow1, styles.ph5]}
formID={ONYXKEYS.FORMS.RULES_REQUIRED_RECEIPT_AMOUNT_FORM}
onSubmit={({maxExpenseAmountNoReceipt}) => {
PolicyActions.setPolicyMaxExpenseAmountNoReceipt(policyID, maxExpenseAmountNoReceipt);
Navigation.setNavigationActionToMicrotaskQueue(Navigation.goBack);
}}
submitButtonText={translate('workspace.editor.save')}
enabledWhenOffline
validate={validate}
> We can apply this solution to other similar cases, such as What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?We created a test for validate to check if the amount is 0. If it is, then errors.maxExpenseAmountNoReceipt should have a value. Otherwise, if the amount is not 0, the error should be {}. What alternative solutions did you explore? (Optional)Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job. Or we can simply return '' for the case DISABLED_MAX_EXPENSE_VALUE (when the user inputs an empty value) to avoid displaying the default max expense value and apply the same logic to the other mentioned cases here and here
if (policy?.maxExpenseAmount === CONST.DISABLED_MAX_EXPENSE_VALUE) {
return '';
} |
Updated to add similar fixes for maxExpenseAmount, maxExpenseAge and policyCategory.maxExpenseAmount |
Job added to Upwork: https://www.upwork.com/jobs/~021869497589885449250 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @allgandalf ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.User unable to save the $0 as amount What is the root cause of that problem?When we enter App/src/libs/actions/Policy/Policy.ts Line 3520 in 154a485
Then we display an empty string here because App/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx Lines 91 to 93 in 154a485
What changes do you think we should make in order to solve the problem?We can simply remove App/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx Lines 91 to 93 in 154a485
We can do the same for What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?NA What alternative solutions did you explore? (Optional)Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job. |
Will review today/ tomorrow |
ProposalPlease re-state the problem that we are trying to solve in this issue.User unable to save the $0 as amount What is the root cause of that problem?The root cause lies in the conditional logic for rendering the field's value. Specifically:
What changes do you think we should make in order to solve the problem?To address this issue, I propose optimizing the conditional logic in the
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?To prevent reintroducing this issue in the future, the following scenarios should be covered in automated tests:
|
📣 @caesaragen! 📣
|
Contributor details |
✅ Contributor details stored successfully. Thank you for contributing to Expensify! |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
@JmillsExpensify, @allgandalf Whoops! This issue is 2 days overdue. Let's get this updated quick! |
@JmillsExpensify, @allgandalf Still overdue 6 days?! Let's take care of this! |
@JmillsExpensify @allgandalf this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks! |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
Proposal from @nkdengineer LGTM, their RCA is correct and solution looks good 🎀👀🎀 C+ reviewed |
My proposal only removes Optional: Another thing we can do here is we can also remove App/src/pages/workspace/rules/RulesReceiptRequiredAmountPage.tsx Lines 37 to 39 in 754817d
|
@allgandalf How did you prove that props like maxExpenseAmountNoReceipt cannot be undefined. You can check the type definition of Policy here Lines 1843 to 1845 in c4b3297
that the prop can be undefined and that's why the code was added in the first place to provide safety. I don't think we have enough info here to remove this safety check. I believe we should handle the root cause of the issue that is caused by using !policy?.maxExpenseAmountNoReceipt instead of correctly checking the type is undefined like My Proposal because using !policy?.maxExpenseAmountNoReceipt will include the value 0 too.
|
The rule can be enabled only in the control workspace. When we upgrade a workspace these values are initialized here. And in the update flow, we also update this to none undefined value. So it's safe to remove this condition App/src/libs/actions/Policy/Policy.ts Lines 3433 to 3435 in 41c38e3
|
@JmillsExpensify, @danieldoglas, @allgandalf Huh... This is 4 days overdue. Who can take care of this? |
📣 @allgandalf 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
📣 @nkdengineer 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
Working through the PR. |
This issue has not been updated in over 15 days. @JmillsExpensify, @danieldoglas, @allgandalf, @nkdengineer eroding to Monthly issue. P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do! |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.94-25 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2025-02-13. 🎊 For reference, here are some details about the assignees on this issue:
|
@allgandalf @JmillsExpensify @allgandalf The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button] |
BugZero Checklist:
Bug classificationSource of bug:
Where bug was reported:
Who reported the bug:
Regression Test ProposalPrecondition:
Test:
Verify that: User able to save the amount. Do we agree 👍 or 👎 |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 9.0.76-12
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @zsgreenwald
Slack conversation (hyperlinked to channel name): expensify_bugs
Action Performed:
Expected Result:
User able to save the amount. (In Classic, an admin has the ability to set the Receipt required amount to $0 to effective set a requirement on all imported CC transactions)
Actual Result:
User unable to save the $0 as amount
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
CleanShot.2024-12-16.at.15.14.23.mp4
Recording.852.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @JmillsExpensifyThe text was updated successfully, but these errors were encountered: