Fix: Error message isn't displayed when create expence with 0 distance#81922
Fix: Error message isn't displayed when create expence with 0 distance#81922lakchote merged 3 commits intoExpensify:mainfrom
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@sobitneupane Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
| const isP2P = isParticipantP2P(getMoneyRequestParticipantsFromReport(report, currentUserAccountIDParam).at(0)); | ||
|
|
||
| if (!value.length || parseFloat(value) < 0) { | ||
| if (!value.length || parseFloat(value) <= 0) { |
There was a problem hiding this comment.
❌ CONSISTENCY-3 (docs)
This change creates duplicated validation logic that already exists on lines 265-268.
Current logic after this change:
- Line 260: Rejects zero distance for ALL cases (P2P and workspace)
- Lines 265-268: Redundantly checks zero distance but ONLY for P2P cases
Issues:
- The validation on line 260 now makes lines 265-268 unreachable for zero values
- The original logic was intentional: allow zero distance for workspace expenses, reject for P2P
- This change breaks the workspace use case where zero distance may be valid
Suggested fix:
Remove the = from line 260 to preserve the original logic, OR if zero distance should be invalid for ALL cases, remove the redundant check on lines 265-268.
If zero should be invalid for all cases:
if (!value.length || parseFloat(value) <= 0) {
setFormError(translate('iou.error.invalidDistance'));
return;
}
// Remove lines 265-268 as they are now redundantIf zero should only be invalid for P2P (original behavior):
if (!value.length || parseFloat(value) < 0) {
setFormError(translate('iou.error.invalidDistance'));
return;
}
// Keep lines 265-268 for P2P-specific zero checkPlease rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.movAndroid: mWeb Chromemchrome.moviOS: HybridAppios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.mov |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
lakchote
left a comment
There was a problem hiding this comment.
Approving and merging @Valforte hope you don't mind, as I need it to unblock #82257 in order to finish the Splits in NewDot project.
|
🚧 @lakchote has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/lakchote in version: 9.3.21-0 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.3.21-4 🚀
|
Explanation of Change
Changed the validation condition from
parseFloat(value) < 0toparseFloat(value) <= 0to catch zero distance values and show the error messageFixed Issues
$ #80053
PROPOSAL: #80053 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand 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-Native.mp4
Android: mWeb Chrome
Android-mWeb.Chrome.mp4
iOS: Native
iOS-Native.mp4
iOS: mWeb Safari
iOS-mWeb.Safari.mp4
MacOS: Chrome / Safari
MacOS-Chrome.mp4