You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD App # 28618] Request & send money - User is redirected to Amount page from Amount page from deep link #29972
Please re-state the problem that we are trying to solve in this issue.
If a user clicks on a link to request money (eg: https://staging.new.expensify.com/request/new), enter an amount, click next and then proceed to click on a link to send money (eg: https://staging.new.expensify.com/send/new), the amount will be pre-populated but after clicking next, it will render the amount screen again. The same happens if you invert the order of the links (send money first and then request money)
What is the root cause of that problem?
The problem is that a single IOU object is used for both send and request money screens. When sending money, the id is send and when requesting money the id is request. When you are in, say, the money screen, enter an amount and click Next, the IOU will be persisted with id = "send". If you then click the request money link, that IOU will be loaded and will still have id = "send". When you click next, the following method will be executed:
IOU.navigateToNextPage(iou,iouType,report);
In this case, iou.id = 'send' and iouType = 'request'.
The first thing this method does is check if the ID of the stored IOU is different than the current IOU being created/edit, and if it is, it will reset the the stored IOU, triggering a screen re-render, which will re-render the amount screen:
constmoneyRequestID=`${iouType}${report.reportID||''}`;constshouldReset=iou.id!==moneyRequestID;// If the money request ID in Onyx does not match the ID from params, we want to start a new request// with the ID from params. We need to clear the participants in case the new request is initiated from FAB.if(shouldReset){resetMoneyRequestInfo(moneyRequestID);}
What changes do you think we should make in order to solve the problem?
This problem does not happen when you use the FAB to initiate Send or Receive money. That's because each of these buttons will first call resetMoneyRequestInfo before loading the screen.
This will stop this issue from happening. When clicking on links, we don't have the opportunity to reset before it loads, causing this problem.
My proposal is to call resetMoneyRequestInfo when the screen is first mounted, on src/pages/iou/MoneyRequestSelectorPage.js, but ONLY if there's a divergence between iou currently in Onyx and the url parameters, as follows:
// reset money request info when screen is first loaded// but only if there's a divergence between current iou and url parametersuseEffect(()=>{if(iou.id===`${iouType}${reportID}`){return;}resetMoneyRequestInfo();},[]);
This will resolve the inconsistence while still allowing user to reload the screen and continue right where it was left off (we will not reset because the url parameters still match current IOU.
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.
Please re-state the problem that we are trying to solve in this issue.
User redirected from amount page to amount page (instead of participants page) when using deep link
What is the root cause of that problem?
The problem occurs when there is a mismatch between iouType (which is found from route params) and iou.id which is found from the IOU value saved in ONYX. So if the value of the iou was 'request' and we are creating 'send' iou or vice versa navigateToNextPage resets the iou value. Because of this line
// If the money request ID in Onyx does not match the ID from params, we want to start a new request
// with the ID from params. We need to clear the participants in case the new request is initiated from FAB.
if(shouldReset){
resetMoneyRequestInfo(moneyRequestID);
}
But the resetMoneyRequestInfo function resets all the iou properties including iou.amount (to 0). So in the MoneyRequestParticipantsPage this lines of code will navigate it back because iou.amount is 0.
// If the money request ID in Onyx does not match the ID from params, we want to start a new request
// with the ID from params. We need to clear the participants in case the new request is initiated from FAB.
if (shouldReset) {
resetMoneyRequestInfo(moneyRequestID, true);
}
`
Result
6.New.Expensify.mp4
What alternative solutions did you explore? (Optional)
The problem is that a single IOU object is used for both send and request money screens, and the id of IOU object will become "" after new request is handled because both sendMoney(send) and createTransaction(request) in MoneyRequestConfirmPage calls resetMoneyRequestInfo function without id.
After clicking request button in MoneyRequestConfirmPage, the id of IOU object will be empty so shouldReset becomes true due to "" !== "request" or "send" and then !isDistanceRequest && ((iou.amount === 0 && !iou.receiptPath) || shouldReset) turns to true so that navigateBack function lets the user to get back to amount page again.
And
if (shouldReset) {
IOU.resetMoneyRequestInfo(moneyRequestId);
}
What changes do you think we should make in order to solve the problem?
Calling the resetMoneyRequestInfo in IOU.js let a user get back to report page automatically but when we visit request/new page directly, we need to take an account if the iou.id is set or not to avoid getting back to amount page again.
in NewRequestAmountPage.js
is used for both sending and requesting money but with opposite id's i.e, When you send money, it's labeled with the "receive" ID, and when you request money, it's labeled "send".
Which results : iou.id = 'send' and iouType = 'request'.
This is handled in navigateToNextPage function
Restested, and now when I go to https://staging.new.expensify.com/request/new I am redirected to a generic error page.
I think this is because the request refactor changed the format of request URLs. @luacmartins thoughts on fixing this?
Perhaps that could be a good pivot for this issue. And instead of going to the above page (where there is no option to leave), we could go to https://staging.new.expensify.com/not-found, which let you go back to the home page.
The /request/new route has been replaced but it's still there because money request routes will catch ANYTHING/new and try to render MoneyRequestSelectorPage. If iouType is invalid, it will render a not-found screen, but request IS valid. The app will continue rendering the old request money screen and it will fail because CONST.TAB.DISTANCE, CONST.TAB.MANUAL, and CONST.TAB.SCAN no longer exist. The same will happen to split (not sure if split have been migrated or not).
To me looks like we're in this transition phase where this route/screen has to exist because send still uses it. Do we plan to transition send as well and eventually get rid of the old screens? If that's the case I suggest we do the following:
This will make it so request/new behaves the same way as invalidioutype/new until everything is migrated away and this routes/screens are completely removed.
Chatted with @luacmartins and there's nothing else we need to fix here. I just need to pay $500 to each of @barros001 and @Ollyws and then close this out. Will take care of that tomorrow!
Activity
melvin-bot commentedon Oct 19, 2023
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
melvin-bot commentedon Oct 19, 2023
Triggered auto assignment to @joekaufmanexpensify (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Oct 19, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Oct 19, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws (
External)barros001 commentedon Oct 19, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
If a user clicks on a link to request money (eg: https://staging.new.expensify.com/request/new), enter an amount, click next and then proceed to click on a link to send money (eg: https://staging.new.expensify.com/send/new), the amount will be pre-populated but after clicking next, it will render the amount screen again. The same happens if you invert the order of the links (send money first and then request money)
What is the root cause of that problem?
The problem is that a single IOU object is used for both send and request money screens. When sending money, the id is
sendand when requesting money the id isrequest. When you are in, say, the money screen, enter an amount and click Next, the IOU will be persisted withid = "send". If you then click the request money link, that IOU will be loaded and will still haveid = "send". When you click next, the following method will be executed:In this case,
iou.id = 'send'andiouType = 'request'.The first thing this method does is check if the ID of the stored IOU is different than the current IOU being created/edit, and if it is, it will reset the the stored IOU, triggering a screen re-render, which will re-render the amount screen:
What changes do you think we should make in order to solve the problem?
This problem does not happen when you use the FAB to initiate Send or Receive money. That's because each of these buttons will first call
resetMoneyRequestInfobefore loading the screen.This will stop this issue from happening. When clicking on links, we don't have the opportunity to reset before it loads, causing this problem.
My proposal is to call
resetMoneyRequestInfowhen the screen is first mounted, onsrc/pages/iou/MoneyRequestSelectorPage.js, but ONLY if there's a divergence betweenioucurrently in Onyx and the url parameters, as follows:This will resolve the inconsistence while still allowing user to reload the screen and continue right where it was left off (we will not reset because the url parameters still match current IOU.
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.
FitseTLT commentedon Oct 19, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
User redirected from amount page to amount page (instead of participants page) when using deep link
What is the root cause of that problem?
The problem occurs when there is a mismatch between
iouType(which is found from route params) andiou.idwhich is found from theIOUvalue saved inONYX. So if the value of the iou was 'request' and we are creating 'send' iou or vice versanavigateToNextPageresets the iou value. Because of this lineApp/src/libs/actions/IOU.js
Lines 2863 to 2871 in eb5fec2
But the
resetMoneyRequestInfofunction resets all the iou properties includingiou.amount(to 0). So in theMoneyRequestParticipantsPagethis lines of code will navigate it back becauseiou.amountis 0.App/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js
Lines 97 to 99 in eb5fec2
What changes do you think we should make in order to solve the problem?
We need to update
resetMoneyRequestInfoto have the option not to reset the amount if needed. Like this,function resetMoneyRequestInfo(id = '', donResetAmount = false) { const created = currentDate || format(new Date(), CONST.DATE.FNS_FORMAT_STRING); Onyx.merge(ONYXKEYS.IOU, { id, ...(!donResetAmount && {amount: 0}), currency: lodashGet(currentUserPersonalDetails, 'localCurrencyCode', CONST.CURRENCY.USD), comment: '', participants: [], merchant: CONST.TRANSACTION.DEFAULT_MERCHANT, category: '', tag: '', created, receiptPath: '', receiptFilename: '', transactionID: '', billable: null, }); }and replace
App/src/libs/actions/IOU.js
Lines 2863 to 2871 in eb5fec2
to
function navigateToNextPage(iou, iouType, report, path = '') { const moneyRequestID =${iouType}${report.reportID || ''}`;const shouldReset = iou.id !== moneyRequestID;
`
Result
6.New.Expensify.mp4
What alternative solutions did you explore? (Optional)
cooldev900 commentedon Oct 19, 2023
Proposal
from: @cooldev900
Please re-state the problem that we are trying to solve in this issue.
If a user clicks on a link to request money (eg: https://staging.new.expensify.com/request/new), enter an amount, click next and then proceed to click on a link to send money (eg: https://staging.new.expensify.com/send/new), the amount will be pre-populated but after clicking next, it will render the amount screen again.
What is the root cause of that problem?
The problem is that a single IOU object is used for both send and request money screens, and the id of IOU object will become
""after new request is handled because both sendMoney(send) and createTransaction(request) in MoneyRequestConfirmPage calls resetMoneyRequestInfo function without id.App/src/libs/actions/IOU.js
Lines 124 to 141 in 8dba113
App/src/pages/iou/steps/MoneyRequestConfirmPage.js
Lines 295 to 311 in 302cebf
App/src/pages/iou/steps/MoneyRequestConfirmPage.js
Lines 295 to 311 in 302cebf
App/src/libs/actions/IOU.js
Lines 1259 to 1279 in 8dba113
App/src/libs/actions/IOU.js
Lines 2513 to 2519 in 8dba113
After clicking request button in MoneyRequestConfirmPage, the id of IOU object will be empty so shouldReset becomes true due to
"" !== "request" or "send"and then!isDistanceRequest && ((iou.amount === 0 && !iou.receiptPath) || shouldReset)turns to true so that navigateBack function lets the user to get back to amount page again.And
could be another reason in next refresh.
App/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js
Lines 92 to 99 in 302cebf
What changes do you think we should make in order to solve the problem?
Calling the resetMoneyRequestInfo in IOU.js let a user get back to report page automatically but when we visit request/new page directly, we need to take an account if the iou.id is set or not to avoid getting back to amount page again.
in NewRequestAmountPage.js
What alternative solutions did you explore? (Optional)
N/A
barros001 commentedon Oct 19, 2023
Proposal
Updated
maxconnectAbhi commentedon Oct 19, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue
If a user clicks on a link to request money (eg: https://staging.new.expensify.com/request/new), enter an amount, click next and then proceed to click on a link to send money (eg: https://staging.new.expensify.com/send/new), the amount will be pre-populated but after clicking next, it will render the amount screen again.
What is the root cause of that problem?
The issue here is that the same IOU object
is used for both sending and requesting money but with opposite id's i.e, When you send money, it's labeled with the
"receive"ID, and when you request money, it's labeled"send".Which results : iou.id = 'send' and iouType = 'request'.
This is handled in navigateToNextPage function
App/src/libs/actions/IOU.js
Lines 2863 to 2871 in 18acd82
which creates the new request
What changes do you think we should make in order to solve the problem?
We need to reset the IOU if id is not matched through
resetMoneyRequestInfo(moneyRequestID)in else case hereApp/src/pages/iou/steps/NewRequestAmountPage.js
Lines 96 to 121 in 18acd82
like
What alternative solutions did you explore? (Optional)
NA
POC
POC.mov
45 remaining items
joekaufmanexpensify commentedon Nov 27, 2023
Same
joekaufmanexpensify commentedon Dec 4, 2023
Still held
joekaufmanexpensify commentedon Dec 11, 2023
Other PR was deployed to staging today. Going to retest there.
joekaufmanexpensify commentedon Dec 11, 2023
Restested, and now when I go to
https://staging.new.expensify.com/request/newI am redirected to a generic error page.I think this is because the request refactor changed the format of request URLs. @luacmartins thoughts on fixing this?
Perhaps that could be a good pivot for this issue. And instead of going to the above page (where there is no option to leave), we could go to
https://staging.new.expensify.com/not-found, which let you go back to the home page.barros001 commentedon Dec 12, 2023
Problem here is the following:
App/src/ROUTES.ts
Lines 247 to 298 in 2d8523a
App/src/libs/Navigation/linkingConfig.ts
Lines 393 to 410 in 2d8523a
App/src/pages/iou/MoneyRequestSelectorPage.js
Lines 123 to 139 in 2d8523a
The
/request/newroute has been replaced but it's still there because money request routes will catchANYTHING/newand try to renderMoneyRequestSelectorPage. IfiouTypeis invalid, it will render a not-found screen, butrequestIS valid. The app will continue rendering the old request money screen and it will fail becauseCONST.TAB.DISTANCE,CONST.TAB.MANUAL, andCONST.TAB.SCANno longer exist. The same will happen tosplit(not sure if split have been migrated or not).To me looks like we're in this transition phase where this route/screen has to exist because
sendstill uses it. Do we plan to transitionsendas well and eventually get rid of the old screens? If that's the case I suggest we do the following:Update the should show check to this:
And get rid of this
ifblock:App/src/pages/iou/MoneyRequestSelectorPage.js
Lines 111 to 141 in 2d8523a
This will make it so
request/newbehaves the same way asinvalidioutype/newuntil everything is migrated away and this routes/screens are completely removed.joekaufmanexpensify commentedon Dec 12, 2023
Ah, actually I think we just fixed that here.
joekaufmanexpensify commentedon Dec 13, 2023
Chatted with @luacmartins and there's nothing else we need to fix here. I just need to pay $500 to each of @barros001 and @Ollyws and then close this out. Will take care of that tomorrow!
joekaufmanexpensify commentedon Dec 14, 2023
@barros001 $500 sent and contract ended!
joekaufmanexpensify commentedon Dec 14, 2023
Upwork job auto closed, so opened a new one to pay @Ollyws
joekaufmanexpensify commentedon Dec 14, 2023
@Ollyws offer sent for $500!
Ollyws commentedon Dec 14, 2023
Accepted, thanks!
joekaufmanexpensify commentedon Dec 14, 2023
Paid! Closing as this is all set.