[Chat] [IOU] Create IOUConfirm step
If you havenβt already, check out our contributing guidelines for onboarding!
Upwork Posting: https://www.upwork.com/jobs/~01744b3390e36e5f36
This issue builds on top of the existing IOU Modal, which was implemented in this PR. The IOU Confirm step page has already been created and is a controlled component (IOUModal manages its state).
The Confirm step allows users to confirm the 'request money' (1:1) or 'bill split'(multiple participants) amount and the participants they are requesting payment from. To open the Modal, you can navigate to localhost:8080/iou/request AND localhost:8080/iou/split.
You can also launch the IOUModal by temporarily modifying the routes in CreateMenu. Launch the request money flow with Navigation.navigate(ROUTES.IOU_REQUEST) and the bill split flow with Navigation.navigate(ROUTES.IOU_BILL)
Mobile & mobile web

Web & Desktop

Deliverables:
- The title should match the title from the Participants step (step 2). This will be 'Split' or 'Request', followed by the amount. (for example: 'Split $42.00' || Request $42.00)
- If the IOU flow is for a bill split, then we should display the current user under the 'WHO PAID?' title (this is not shown for the request money flow)
- We then need to display all participants other than the current user. With the amount that they will need to pay (total amount, split equally between amount of participants)
- If 'Bill split' flow, then we should reuse the list from the IOUParticipantsSplit page
- If 'Request money' flow, then we simply display a single user under the 'To' heading
- An input field should allow the user to input an optional comment for the IOU request
- The button label should read 'Request $[currency][amount]' or 'Split bill' if there are multiple participants
- A new API function should be created within
API.js:createIOUTransaction, which will be called from IOUModal to create the IOU (details for this request can be found below). - When the user hits this button, we should pass the comment input string up to IOUModal via the existing
onStepCompletecallback (or something similar), and we should then call the newcreateIOUTransactionAPI function from within a new IOUAction function.- We should show a loading indicator in the button (using ButtonWithLoader), by setting the Onyx IOU key to
IOU: {loading:true}. We should display a loading indicator in the Button while this is true. - Within this new IOUAction function we should await a successful response to
createIOUTransaction, and then pass the returnedreportIDvalue toGetIOUReport, to retrieve the full IOUReport details - Then, we should persist the simplified version of these details to Onyx, just like we are doing here
- We should show a loading indicator in the button (using ButtonWithLoader), by setting the Onyx IOU key to
- Finally, back in IOUModal we should subscribe to the
reportIOU_Onyx key. Once we notice that the new IOU data has been persisted to Onyx (when we persist the data in step 7, we should receive this in our Onyx subscription). Once this value is not null, we know that the report has successfully been created and persisted to Onyx, so we can close the IOU Modal.
CreateIOUTransaction API Example of the API which is used to create the IOU request / split.
curl --request POST \
--url 'https://expensify-jules.ngrok.io/api?command=CreateIOUTransaction' \
--header 'Content-Type: multipart/form-data; boundary=---011000010111000001101001' \
--cookie 'email=jules%252B3%2540expensify.com; accountID=12; authToken=66ADF90...22AE918' \
--form [email protected] \
--form currency=USD \
--form 'comment=Pizza π' \
--form amount=550
Expensify/Expensify Issue URL: https://github.com/Expensify/Expensify/issues/157782
Hey @Jag96, I notice you have self-assigned this issue. Is it still pending a proposal? In that case, I would like to contribute to this issue. The issue's a continuity to an earlier issue I contributed in: #1694
My proposal:
-
Modify
getTitleForStepin IOUModal to match the title from IOUParticipants step for the IOUConfirmation page -
We have two ways to render a page:
I. If it's Bill Split: - In the IOUConfirmation step, add a Text component with the "WHO PAID" label at the beginning of the page. Under the text, we display the current user with a tick mark next to them using `OptionRow` - Then, in the second section of the page, we display "WHO WAS THERE" text similarly - We reuse the `OptionsSelector` list that is used on the `IOUParticipantsSplit` page II. If it's Request: - Add a text component with "TO" label at the beginning of the page. - Use `OptionRow` to display the participant without a tick mark. -
An input field should be added within both flows to ask the user for an optional comment for the request. I will reuse the
TextInputWithFocusStylesfor this purpose. -
Finally, the button label should have conditional logic to display either 'Request $[currency][amount]' | 'Split bill' based on the flow
-
I will create a new API.js function called:
createIOUTransactionto create the IOU -
I will use the existing
onStepCompletecallback to callcreateIOUTransactionAPI function within a new async createNewTransaction function inIOUAction -
Within the function, we will set loading true for the Onyx IOU key by setting it as
Onyx.merge(ONYXKEYS.IOU, {loading: true})before calling createIOUTransaction. I will pass this loading to the button loader's isLoading prop. -
We then await a successful response to
createIOUTransactionand pass the returnedreportIDto getIOUReportusingGetIOUReport -
We then set loading false for the Onyx IOUKey as well by setting it as:
Onyx.merge(ONYXKEYS.IOU, {loading: false}); -
Moreover, we persist the simplified version of the report we get from
getSimplifiedIOUReport(iouReport)in Onyx. -
Also, I will subscribe
IOUModalto thereportIOU_ Onyxkey, so that when we persist a report in the above step, theIOUModalreceives the event. When it does, we will know that the report has been successfully created, so we can close theIOUModal
Hi, I would like to work on this issue. Here is my proposal:
- The title should match the title from the Participants step (step 2). This will be 'Split' or 'Request', followed by the amount. (for example: 'Split $42.00' || Request $42.00)
I will modify first if condition here to have same title with Participants step: https://github.com/Expensify/Expensify.cash/blob/fa6185b2c51fdc0f28ab9cbc48b8a306f64a537d/src/pages/iou/IOUModal.js#L65-L73
- If the IOU flow is for a bill split, then we should display the current user under the 'WHO PAID?' title (this is not shown for the request money flow)
I will pass hasMultipleParticipants prop to IOUConfirmPage component to distinguish bill split and request money. If it is a bill split, I will show 'WHO PAID?' title.
We then need to display all participants other than the current user. With the amount that they will need to pay (total amount, split equally between amount of participants)
- If 'Bill split' flow, then we should reuse the list from the IOUParticipantsSplit page
I will pass participants array from IOUModal's state to IOUConfirmPage component as a prop. With iouAmount and participants list, I will calculate the amount they will need to pay within IOUConfirmPage component.
https://github.com/Expensify/Expensify.cash/blob/fa6185b2c51fdc0f28ab9cbc48b8a306f64a537d/src/pages/iou/IOUModal.js#L48
- If 'Request money' flow, then we simply display a single user under the 'To' heading
Again, using hasMultipleParticipants prop, I will show 'To' heading with single participant.
- An input field should allow the user to input an optional comment for the IOU request
I will add TextInputFocusable element for optional comment.
- The button label should read 'Request $[currency][amount]' or 'Split bill' if there are multiple participants
Again, using hasMultipleParticipants prop, I will have custom button label.
- A new API function should be created within
API.js:createIOUTransaction, which will be called from IOUModal to create the IOU (details for this request can be found below).
I will create an API function that makes a POST request with CreateIOUTransaction command with required fields similar to this one:
https://github.com/Expensify/Expensify.cash/blob/4bc32214cd2158a02053da8bf6c3619ad3505d63/src/libs/API.js#L486-L491
- When the user hits this button, we should pass the comment input string up to IOUModal via the existing
onStepCompletecallback (or something similar), and we should then call the newcreateIOUTransactionAPI function from within a new [IOUAction] (https://github.com/Expensify/Expensify.cash/blob/fa6185b2c51fdc0f28ab9cbc48b8a306f64a537d/src/libs/actions/IOU.js) function.
I will add a function in IOUModal that calls createIOUTransaction API function and I will pass this function to IOUConfirmPage as onStepComplete prop.
- We should show a loading indicator in the button (using ButtonWithLoader), by setting the Onyx IOU key to
IOU: {loading:true}. We should display a loading indicator in the Button while this is true.
In this new function, I will update Onyx IOU key to IOU: {loading:true} .
- Within this new IOUAction function we should await a successful response to
createIOUTransaction, and then pass the returnedreportIDvalue toGetIOUReport, to retrieve the full IOUReport details
I'm going to use promise and then to await API call to pass returned reportID value to GetIOUReport.
- Then, we should persist the simplified version of these details to Onyx, just like we are doing here
Then I will update Onyx with new data.
- Finally, back in IOUModal we should subscribe to the
reportIOU_Onyx key. Once we notice that the new IOU data has been persisted to Onyx (when we persist the data in step 7, we should receive this in our Onyx subscription). Once this value is not null, we know that the report has successfully been created and persisted to Onyx, so we can close the IOU Modal.
I will add withOnyx to IOUModal in order to subscribe to the reportIOU_ Onyx key.
https://github.com/Expensify/Expensify.cash/blob/10a21d6778da60aa913f820e2c93888efb585a9e/src/pages/iou/steps/IOUConfirmPage.js#L45-L47
Thanks for both of your submissions. We'll go with @barun1997 as his submission was first.
We have more IOU issues on the way!
@Julesssss Thanks for the assignment! I will start working on it right away.
@Jag96 I've applied for the job posting in Upwork. Please kindly take a look.
Hi @Julesssss, I am working to complete this issue, but I just wanted to gain some clarity on createIOUTransaction. After a successful transaction creation, it returns a reportID. In the issue note:
2\. Within this new IOUAction function we should await a successful response to `createIOUTransaction`, and then pass the returned `reportID` value to `GetIOUReport`, to retrieve the full IOUReport details
it is mentioned that this reportID should be passed to GetIOUReport but GetIOUReport expects debtorEmail.
https://github.com/Expensify/Expensify.cash/blob/2b0674b94819926f38e71b4c5c8edf25bebe1ecb/src/libs/API.js#L628-L632
So, my thought process is to instead implement it the way it's implemented in actions/Report.js since we already have a reportID:
https://github.com/Expensify/Expensify.cash/blob/2b0674b94819926f38e71b4c5c8edf25bebe1ecb/src/libs/actions/Report.js#L228-L241
Please let me know if I'm missing something!
it is mentioned that this reportID should be passed to GetIOUReport but GetIOUReport expects debtorEmail.
Ah yes, this changed recently. I should have let you know. You've got it though, that would be the ideal solution π
Let us know if you have any other questions!
Ahh, gotcha! Thank you.
@Julesssss, just a final question regarding API call for CreateIOUTransaction for Split Bills.
The example is:
curl --request POST \
--url 'https://expensify.com/api?command=CreateIOUTransaction' \
--header 'Content-Type: multipart/form-data; boundary=---011000010111000001101001' \
--cookie 'email=jules%252B3%2540expensify.com; accountID=12; authToken=66ADF90...22AE918' \
--form [email protected] \
--form currency=USD \
--form 'comment=Pizza π' \
--form amount=550
It works perfectly when I send a single debtorEmail, but for Split, we'd have multiple emails. Could you give me an example for CreateIOUTransaction in the case of a Split Bill? Thank you for your help!
Ah yes, this is a totally different API. I probably should have shared all of them, rather than those I thought would be necessary π
/CreateIOUSplit
curl --request POST \
--url 'https://expensify.com/api?command=CreateIOUSplit' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--cookie 'email=REDACTED; accountID=REDACTED; authToken=REDACTED' \
--data reportID=786 \
--data amount=100 \
--data currency=USD \
--data 'splits=[{"amount":50,"email":"[email protected]"},{"amount":50,"email":"[email protected]"}]'
Haha! Makes sense now. Thank you! @Julesssss
Can you please link to your draft PR once you have one @barun1997?
Reopening this, it seems that there is still a regression related to the original fix. cc @barun1997
I will take a look, thank you!
Hi, I looked at this issue today, but still can't seem to wrap my head around it to find a proper solution. The problem is that I fixed the original solution by restricting it to flexGrow0 so it doesn't take the remaining space. But if I do let it default to flex1, this allows it to scroll, but it takes all the available space.

I will make another try tomorrow, but I'm open to your suggestions!
I don't have any specific suggestions, but it might be worth sharing the problem in the expensify-open-source channel to get more eyes on the problem.
@Julesssss Thank you! I have shared it in the Slack Group.
@barun1997 have you done any further investigation on how to fix this?
Hi, just to be clear on the specification required:
Is this something we're looking for? https://www.loom.com/share/68ef6b07a742462b955680c094189834
I think I've figured out a solution for this! If this is the desired solution :)
Having the input at the bottom with only a few participants is not ideal.
I'm tagging @shawnborton, who may have some ideas on how to solve the scrolling problem.
@Julesssss That's no longer a problem now, fortunately! Just wondering if the scroll action (with comment fixed as in the video) is the desired UX?