-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Modify MoneyRequestConfirmPage
for Distance Request
#25707
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This draft looks like it's still in a pretty early stage so I don't want to comment on too much. I did notice this though and it might be something to consider.
I'm going to take dinner break now but I gonna work on the following when I come back:
|
Update: Working on this part of the design doc where I need to extract the mileage rate from the policy associated with the report (where the money/distance request is create) and the distance itself from the transaction. We need these values to calculate the expense amount to be displayed on the confirmation page. |
TODO
|
🚀 Deployed to staging by https://github.com/neil-marcellini in version: 1.3.62-0 🚀
|
Ok I went through almost all the bugs reported here and report them in Slack and created GH issues for them. If I missed any I'm sure we'll see them reported again eventually. |
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.62-4 🚀
|
} | ||
|
||
const amount = DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate); | ||
IOU.setMoneyRequestAmount(amount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming from #26946.
I'm trying to figure out this props.iouAmount === 0
-> setMoneyRequestAmount
-> props.iouAmount !== 0
cycle to review the proposals properly.
Would it be fine to drop the props.iouAmount === 0
condition and do something like:
// useMemo if we consider this heavy
const distanceAmmount = props.isDistanceRequest ? DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate) : undefined;
const formattedAmount = distanceAmmount !== undefined ?
CurrencyUtils.convertToDisplayString(distanceAmmount, currency) :
CurrencyUtils.convertToDisplayString(props.iouAmount, props.iouCurrencyCode);
useEffect(() => {
if (distanceAmmount !== undefined) {
IOU.setMoneyRequestAmount(distanceAmmount);
}
}, [distanceAmmount]);
...or would it mess with the original intention/semantics of the props.iouAmount === 0
check, in the way I'm missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Continuing here)
@cubuspl42 could you link the code please 🙇 |
const shouldCalculateDistanceAmount = props.isDistanceRequest && props.iouAmount === 0; | ||
const shouldCategoryEditable = !_.isEmpty(props.policyCategories) && !props.isDistanceRequest; | ||
|
||
const formattedAmount = CurrencyUtils.convertToDisplayString( | ||
shouldCalculateDistanceAmount ? DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate) : props.iouAmount, | ||
props.isDistanceRequest ? currency : props.iouCurrencyCode, | ||
); | ||
|
||
useEffect(() => { | ||
if (!shouldCalculateDistanceAmount) { | ||
return; | ||
} | ||
|
||
const amount = DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate); | ||
IOU.setMoneyRequestAmount(amount); | ||
}, [shouldCalculateDistanceAmount, distance, rate, unit]); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hayata-suenaga Well, I was speaking in the context of the mentioned line and its direct surroundings, but specifically, I'm talking about this range of lines, focusing on checking if props.iouAmount
equals 0
and the dependencies of the useEffect
hook.
This code cause the bug I mentioned earlier and we're trying to figure out whether we can just drop the props.iouAmount === 0
check without causing a regression.
One option how this area could look like after the change was included in my previous message. Let's continue the discussion in this thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh now I see what's you're talking about
we actually need that conditional statement
when the user manually edit the distance amount, we want to keep that amount instead of overwriting it with the calculated amount
but I know see why this is causing the issue
can we just clear out the amount from Transaction object when navigating back to the participants page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just clear out the amount from Transaction object when navigating back to the participants page?
I'm not completely sure, I'll come back to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when the user manually edit the distance amount, we want to keep that amount instead of overwriting it with the calculated amount
Users can't edit the distance amount manually (we prevented user clicking on the amount field), they only can edit the waypoint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DylanDylann Is it a temporary measure, or can we (at least for now) take this for granted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a GH issue to re-add the ability to edit the amount manually?
We're in a tricky situation here. Currently, the simplest way to fix #26946 is just dropping the === 0
check, taking advantage from the fact that the amount cannot be (currently) edited by the user.
If we assume that that amount can be edited (because the feature might be re-added), we'd probably have to add some new persistent state to distinguish manually edited value from the auto-calculated one, but wouldn't be able to test it properly.
There are multiple solutions to this problem, but I would prefer to do it this way: for now, let's remove the === 0
condition, fixing #26946. Then, comment on the GH issue to re-add the manual edition feature to take care not to introduce regression for #26946 (creating new persistent state, if needed).
If there's no issue for re-adding manual distance IOU amount edition, we can create it.
This way, we're be focusing on problems we have right now, but at the same time do our best not to introduce regressions. This will also do fine in a hypothetical case we actually never re-allow manual edition (but such case wouldn't surprise me).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rather prefer if you could handle it in your issue @cubuspl42 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hayata-suenaga But how would you suggest to test that it achieves the goal, if it's currently not possible to manually edit the amount?
Maybe we could introduce a beta for editing the distance request amount, so this can be tested locally via manual one-line edition in Permissions.js
, while the QA could be opted in to that beta on the backend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not totally following everything discussed here, but I am chiming in to say that I am working on a PR #26141 to let people edit the distance request, and it will allow users to edit the amount as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cubuspl42 you can hold your issue on the above PR if necessary
@@ -59,6 +59,7 @@ const defaultProps = { | |||
|
|||
function MoneyRequestConfirmPage(props) { | |||
const {windowHeight} = useWindowDimensions(); | |||
const isDistanceRequest = props.selectedTab === CONST.TAB.DISTANCE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this condition caused #26661. We should have considered adding a check which verified the iouType
here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a refactor on the URLs related to money requests so that we can embed the info on the kind of money requests being made inside the URL so we don't have to this kind of awkward conditional checks
@@ -42,7 +42,7 @@ class WorkspaceRateAndUnitPage extends React.Component { | |||
getUnitItems() { | |||
return [ | |||
{label: this.props.translate('workspace.reimburse.kilometers'), value: CONST.CUSTOM_UNITS.DISTANCE_UNIT_KILOMETERS}, | |||
{label: this.props.translate('workspace.reimburse.miles'), value: CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES}, | |||
{label: this.props.translate('common.miles'), value: CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change has introduced a regression fixed in this PR: #27640 - these two units translations are inconsistent in terms of capitalization
<MapView | ||
accessToken={mapboxToken} | ||
mapPadding={CONST.MAP_PADDING} | ||
pitchEnabled={false} | ||
directionCoordinates={coordinates} | ||
directionStyle={styles.mapDirection} | ||
style={styles.mapView} | ||
waypoints={waypointMarkers} | ||
styleURL={CONST.MAPBOX_STYLE_URL} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could pass initialState
prop with start waypoint to avoid locating wrong location on first render.
Issue: #26726
@@ -58,7 +62,7 @@ function MoneyRequestParticipantsPage(props) { | |||
// ID in Onyx could change by initiating a new request in a separate browser tab or completing a request | |||
if (prevMoneyRequestId.current !== props.iou.id) { | |||
// The ID is cleared on completing a request. In that case, we will do nothing | |||
if (props.iou.id) { | |||
if (!isDistanceRequest && props.iou.id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have navigated the user back if it was a distance request having empty waypoints. This caused #27383
@@ -1370,6 +1370,9 @@ const CONST = { | |||
MAKE_REQUEST_WITH_SIDE_EFFECTS: 'makeRequestWithSideEffects', | |||
}, | |||
|
|||
MAP_PADDING: 50, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This MAP_PADDING
value caused the following issue:
Because the value was too high, on certain narrow layout devices (mobile) the value caused the app to crash when submitting a distance request. The issue was fixed by decreasing the value to 32
and removing / unifying the MAP_PADDING
into using MAPBOX.PADDING
variable instead. More details can be found in the issue / proposal.
@tgolen
Details
Display a map with the distance route on
MoneyRequestConfirmPage
.Fixed Issues
$ #22710
Tests / QA
Creating a distance request from a workspace chat
Test 1: Check Distance Request is only available in Workspace chats and Global Create
Video walkthrough
Screen.Recording.2023-08-29.at.5.19.57.PM.mov
Distance Request should be only available for Workspace chats and Global Create. In non-workspace chats, the Distance Request tab should not be visible
Test 2: Create a distance request from a Workspace chat
🔔 Test steps 20 ~ 24 are not ready. Waiting for other PR. The video walkthrough is for Steps 1 ~ 19
Video walkthrough
Screen.Recording.2023-08-29.at.4.46.06.PM.mov
Go to a Workspace chat. If you don't have a workspace yet, create one.
Click the "+" button in the text field.
Click "Request money" on the popup
Click the "Distance" tab on the next screen that appears
Click the "Start" item in the list of waypoints
On the text field in the next screen, type
88 Kearny Street
. Select the first option.Click the "Finish" item in the list of waypoints
On the text field in the next screen, type "1 Telegraph Hill". Click the first option that appears.
Click the "Next" button
Confirm that the next screen (Money Request Confirm Page) looks like the screenshot below. Check "Amount" is
$0.92
.Click "Show more" and confirm the screen looks like below.
Check you're taken back to the previous (Distance Request) screen. Click "Next" button again.
Click "Date". Check you can change and save the date.
Click "Description". Check you can add and save the description.
At this time, we won't check if "Amount" will work or not. Click "Request
$0.92
button at the bottom.Confirm that the Right Hand Panel (where we were creating the distance request) is closed
Confirm you're still in the same workspace chat and a new distance request is created.
Click the distance request created.
Confirm that you're taken to the distance request details page. Confirm information displayed is the same information you inputted.
Go back to the workspace chat and create another distance request. Confirm that the map is reset to the initial state without any waypoints or route drawn.
Click "Next" and this time, click "Amount"
Try to click the dollar sign "$". Check that nothing happens when you click it (to confirm the currency is not editable)
Edit the amount and save. Confirm the amount is updated on the confirmation page. Click "Request
$<new amount>
" at the bottom to create the new distance request.Check the newly created distance request has the correct amount to which you changed.
Test 3: Create a distance request through Global Create
Video walkthrough
global_create_test.mov
Make sure you existing chats other than the test workspace.
Click the Global Create button (the floating "+" button).
Click "Request Money"
Repeat the steps from steps 4 - 9 from the first test.
Check the next screen appears looks like the screenshot below. On this screen, you can select to who/where you make distance request. Make sure that only workspace(s) appear as options. Make sure that no personal account appears as selections (step 1 was for this purpose).
Select a workspace and confirm that the next screen that appears looks like the screenshot from step 10 of the first test (Confirm page).
Offline tests
Video walkthrough
Screen.Recording.2023-08-29.at.10.08.25.PM.mov
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Please refer to the screen recordings for Tests #1 #2, and #3 above
Mobile Web - Chrome
Screen.Recording.2023-08-29.at.10.25.21.PM.mov
Mobile Web - Safari
Screen.Recording.2023-08-29.at.10.20.37.PM.mov
Desktop
Screen.Recording.2023-08-29.at.10.18.15.PM.mov
iOS
Screen.Recording.2023-08-29.at.10.35.16.PM.mov
Android
My development environment is not working for Android