Skip to content
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

[HOLD App # 28618] Request & send money - User is redirected to Amount page from Amount page from deep link #29972

Closed
6 tasks done
lanitochka17 opened this issue Oct 19, 2023 · 53 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review

Comments

@lanitochka17
Copy link

lanitochka17 commented Oct 19, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 1.3.87-1

Reproducible in staging?: Yes

Reproducible in production?: Yes

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: Applause - Internal Team

Slack conversation:

Issue found when executing PR #29655

Action Performed:

  1. Go to staging.new.expensify.com
  2. Paste Request money link (https://staging.new.expensify.com/request/new
    ) to any chat,
    3, Click on the link above.
  3. Enter amount and click Next.
  4. Repeat Step 2-4 with Send money link (https://staging.new.expensify.com/send/new
    ).

Expected Result:

User will be redirected to the next step of the Request money/Send money process

Actual Result:

The process is looped. Instead of proceeding to the next step, user lands on the enter amount page again

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Bug6242961_1697721243249.20231019_195657.mp4
MacOS: Desktop

View all open jobs on GitHub

@lanitochka17 lanitochka17 added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 19, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 19, 2023

Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

@melvin-bot
Copy link

melvin-bot bot commented Oct 19, 2023

Triggered auto assignment to @joekaufmanexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 19, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 19, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@melvin-bot
Copy link

melvin-bot bot commented Oct 19, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws (External)

@barros001
Copy link
Contributor

barros001 commented 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 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:

    const moneyRequestID = `${iouType}${report.reportID || ''}`;
    const shouldReset = 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.

function startMoneyRequest(iouType, reportID = '') {
    resetMoneyRequestInfo(`${iouType}${reportID}`);
    Navigation.navigate(ROUTES.MONEY_REQUEST.getRoute(iouType, reportID));
}

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 parameters
    useEffect(() => {
        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.

@FitseTLT
Copy link
Contributor

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) 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

App/src/libs/actions/IOU.js

Lines 2863 to 2871 in eb5fec2

function navigateToNextPage(iou, iouType, report, path = '') {
const moneyRequestID = `${iouType}${report.reportID || ''}`;
const shouldReset = 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);
}

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 (!isDistanceRequest && ((iou.amount === 0 && !iou.receiptPath) || shouldReset)) {
navigateBack(true);
}

What changes do you think we should make in order to solve the problem?

We need to update resetMoneyRequestInfo to 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

function navigateToNextPage(iou, iouType, report, path = '') {
const moneyRequestID = `${iouType}${report.reportID || ''}`;
const shouldReset = 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);
}

to

function navigateToNextPage(iou, iouType, report, path = '') { const moneyRequestID =${iouType}${report.reportID || ''}`;
const shouldReset = 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, true);
}

`
Result

6.New.Expensify.mp4

What alternative solutions did you explore? (Optional)

@cooldev900
Copy link
Contributor

cooldev900 commented 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

function resetMoneyRequestInfo(id = '') {
const created = currentDate || format(new Date(), CONST.DATE.FNS_FORMAT_STRING);
Onyx.merge(ONYXKEYS.IOU, {
id,
amount: 0,
currency: lodashGet(currentUserPersonalDetails, 'localCurrencyCode', CONST.CURRENCY.USD),
comment: '',
participants: [],
merchant: CONST.TRANSACTION.DEFAULT_MERCHANT,
category: '',
tag: '',
created,
receiptPath: '',
receiptFilename: '',
transactionID: '',
billable: null,
});
}

const sendMoney = useCallback(
(paymentMethodType) => {
const currency = props.iou.currency;
const trimmedComment = props.iou.comment.trim();
const participant = participants[0];
if (paymentMethodType === CONST.IOU.PAYMENT_TYPE.ELSEWHERE) {
IOU.sendMoneyElsewhere(props.report, props.iou.amount, currency, trimmedComment, props.currentUserPersonalDetails.accountID, participant);
return;
}
if (paymentMethodType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY) {
IOU.sendMoneyWithWallet(props.report, props.iou.amount, currency, trimmedComment, props.currentUserPersonalDetails.accountID, participant);
}
},
[props.iou.amount, props.iou.comment, participants, props.iou.currency, props.currentUserPersonalDetails.accountID, props.report],
);

const sendMoney = useCallback(
(paymentMethodType) => {
const currency = props.iou.currency;
const trimmedComment = props.iou.comment.trim();
const participant = participants[0];
if (paymentMethodType === CONST.IOU.PAYMENT_TYPE.ELSEWHERE) {
IOU.sendMoneyElsewhere(props.report, props.iou.amount, currency, trimmedComment, props.currentUserPersonalDetails.accountID, participant);
return;
}
if (paymentMethodType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY) {
IOU.sendMoneyWithWallet(props.report, props.iou.amount, currency, trimmedComment, props.currentUserPersonalDetails.accountID, participant);
}
},
[props.iou.amount, props.iou.comment, participants, props.iou.currency, props.currentUserPersonalDetails.accountID, props.report],
);

App/src/libs/actions/IOU.js

Lines 1259 to 1279 in 8dba113

function splitBillAndOpenReport(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, category) {
const {splitData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, category);
API.write(
'SplitBillAndOpenReport',
{
reportID: splitData.chatReportID,
amount,
splits: JSON.stringify(splits),
currency,
comment,
category,
transactionID: splitData.transactionID,
reportActionID: splitData.reportActionID,
createdReportActionID: splitData.createdReportActionID,
policyID: splitData.policyID,
},
onyxData,
);
resetMoneyRequestInfo();

App/src/libs/actions/IOU.js

Lines 2513 to 2519 in 8dba113

function sendMoneyElsewhere(report, amount, currency, comment, managerID, recipient) {
const {params, optimisticData, successData, failureData} = getSendMoneyParams(report, amount, currency, comment, CONST.IOU.PAYMENT_TYPE.ELSEWHERE, managerID, recipient);
API.write('SendMoneyElsewhere', params, {optimisticData, successData, failureData});
resetMoneyRequestInfo();
Navigation.dismissModal(params.chatReportID);

image

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);
  }

could be another reason in next refresh.

const moneyRequestId = `${iouType.current}${reportID.current}`;
const shouldReset = iou.id !== moneyRequestId;
if (shouldReset) {
IOU.resetMoneyRequestInfo(moneyRequestId);
}
if (!isDistanceRequest && ((iou.amount === 0 && !iou.receiptPath) || shouldReset)) {
navigateBack(true);
}

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

useEffect(() => {
        if (!iou.id && (lodashGet(route, 'params.iouType', '') === CONST.IOU.TYPE.REQUEST || lodashGet(route, 'params.iouType', '') === CONST.IOU.TYPE.SEND)) {
            IOU.resetMoneyRequestInfo(lodashGet(route, 'params.iouType', ''));
        }
    }, [iou.id, route.params])

What alternative solutions did you explore? (Optional)

N/A

@barros001
Copy link
Contributor

Proposal

Updated

@maxconnectAbhi
Copy link

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

{
amount:0
category:""
comment:""
created:"2023-10-19"
currency:"INR"
id:"request"
merchant:"Request"
participants:[]
receiptFilename:""
receiptPath:""
tag:""
transactionID:"8311076577222983710"
}

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

function navigateToNextPage(iou, iouType, report, path = '') {
const moneyRequestID = `${iouType}${report.reportID || ''}`;
const shouldReset = 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);
}

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 here

useEffect(() => {
if (isEditing) {
// ID in Onyx could change by initiating a new request in a separate browser tab or completing a request
if (prevMoneyRequestID.current !== iou.id) {
// The ID is cleared on completing a request. In that case, we will do nothing.
if (!iou.id) {
return;
}
Navigation.goBack(ROUTES.MONEY_REQUEST.getRoute(iouType, reportID), true);
return;
}
const moneyRequestID = `${iouType}${reportID}`;
const shouldReset = iou.id !== moneyRequestID;
if (shouldReset) {
IOU.resetMoneyRequestInfo(moneyRequestID);
}
if (!isDistanceRequestTab && (_.isEmpty(iou.participants) || iou.amount === 0 || shouldReset)) {
Navigation.goBack(ROUTES.MONEY_REQUEST.getRoute(iouType, reportID), true);
}
}
return () => {
prevMoneyRequestID.current = iou.id;
};
}, [iou.participants, iou.amount, iou.id, isEditing, iouType, reportID, isDistanceRequestTab]);

like

else{
            const moneyRequestID = `${iouType}${reportID}`;
            const shouldReset = iou.id !== moneyRequestID;
            if (shouldReset) {
                IOU.resetMoneyRequestInfo(moneyRequestID);
            }

What alternative solutions did you explore? (Optional)

NA

POC

POC.mov

@joekaufmanexpensify
Copy link
Contributor

Def seems like a bug. @Ollyws thoughts on the above proposals?

@melvin-bot melvin-bot bot added the Overdue label Oct 23, 2023
@Ollyws
Copy link
Contributor

Ollyws commented Oct 23, 2023

Will have a look at this one today.

@melvin-bot melvin-bot bot removed the Overdue label Oct 23, 2023
@joekaufmanexpensify
Copy link
Contributor

Great, ty!

@Ollyws
Copy link
Contributor

Ollyws commented Oct 23, 2023

Thanks for the proposals everyone.

@barros001, there was a previous PR that did exactly what you are suggesting but it was reverted due to causing multiple regressions, so I think we best avoid that solution.

@FitseTLT The problem is that we're calling resetMoneyRequestInfo when we navigate to the next page due to the fact that iou.id (Onyx data) and iouType (route param) don't match, better to make sure we have the correct values initially rather than applying a work-around.

@cooldev900 Still considering yours, will need to do a little more testing.

@maxconnectAbhi Correct me if I'm wrong but I'm not sure how your proposal would work as you're suggesting we modify code inside the isEditing block, which isn't being called here as far as I can see unless we're editing.

@barros001
Copy link
Contributor

@Ollyws Got it. That PR does look pretty similar to what I tried locally, so yeah, let's avoid that. What about my alternative solution? The idea is to simply reset the IOU every time the screen is first loaded. It's similar to what startMoneyRequest does, but because the route is being loaded from a link, we don't have a chance to reset it before it loads. So instead we reset it on the component level, when the screen loads using, for example:

    useEffect(() => {
        resetMoneyRequestInfo();
    }, []);

Also, we would do it on MoneyRequestSelectorPage.js instead of NewRequestAmountPage.js as NewRequestAmountPage, NewDistanceRequestPage and ReceiptSelector all depend on IOU and not reseting them when on any of the other screens could have unexpected site effects just like this one we're dealing with.

@maxconnectAbhi
Copy link

@Ollyws No I am not modifying code inside isEditing block , Its in else condition.

@peterdbarkerUK
Copy link
Contributor

@Ollyws - do you think the bug report here is derivative/has the same root cause as this issue?

@Ollyws
Copy link
Contributor

Ollyws commented Oct 24, 2023

They are related in that they're both due to a mismatch of the Onyx data and the route param, but I'm not sure the solutions would overlap.

This one seems to be because we never clear the Onyx data when navigating via deeplink and are therefore left with stale data which doesn't match the route param, so clearning it initially when we navigate via deeplink (to match what we do when we navigate via the menu) seems to be the correct solution here.

Whereas from what I can see #30060 seems to be because we set the Onyx data for the request type when we navigate to the confirmation step, and it's retained when we navigate back.

@joekaufmanexpensify
Copy link
Contributor

Ongoing discussion about solutions

@joekaufmanexpensify
Copy link
Contributor

@Ollyws curious if you think we're close to being able to select any of these proposals?

@joekaufmanexpensify
Copy link
Contributor

Still pending more discussion on proposals

@joekaufmanexpensify
Copy link
Contributor

All good, and sounds good!

@barros001
Copy link
Contributor

barros001 commented Nov 6, 2023

Well, it was a lot faster than I thought it would be, my account was verified already and I applied for the job via Upwork.

@joekaufmanexpensify
Copy link
Contributor

@barros001 offer sent for $500! Please let us know once the PR is ready for review.

@barros001
Copy link
Contributor

PR is ready for review. Just pending attaching video for Android native, will do as soon as I can get it to run on my dev machine.

@luacmartins
Copy link
Contributor

I'll put this issue on hold for #28618, since that refactor should fix this.

@luacmartins luacmartins changed the title Request & send money - User is redirected to Amount page from Amount page from deep link [HOLD App # 28618] Request & send money - User is redirected to Amount page from Amount page from deep link Nov 8, 2023
@Ollyws
Copy link
Contributor

Ollyws commented Nov 8, 2023

Just to note: According to section 19 of the process doc, in this situation payment is due for the C+ and contributor. Thanks.

@joekaufmanexpensify
Copy link
Contributor

Yep, I agree! We'll wait and see if that PR fixes this issue. If it does, we'll still issue payment and close this out. If not, we'll proceed with the PR.

@joekaufmanexpensify
Copy link
Contributor

Held

@joekaufmanexpensify
Copy link
Contributor

Same

@joekaufmanexpensify
Copy link
Contributor

Still held

@joekaufmanexpensify
Copy link
Contributor

Other PR was deployed to staging today. Going to retest there.

@joekaufmanexpensify joekaufmanexpensify added Daily KSv2 and removed Weekly KSv2 labels Dec 11, 2023
@joekaufmanexpensify
Copy link
Contributor

Restested, and now when I go to https://staging.new.expensify.com/request/new I am redirected to a generic error page.

image

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.

image

@barros001
Copy link
Contributor

Problem here is the following:

App/src/ROUTES.ts

Lines 247 to 298 in 2d8523a

MONEY_REQUEST: {
route: ':iouType/new/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/${reportID}` as const,
},
MONEY_REQUEST_AMOUNT: {
route: ':iouType/new/amount/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/amount/${reportID}` as const,
},
MONEY_REQUEST_PARTICIPANTS: {
route: ':iouType/new/participants/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/participants/${reportID}` as const,
},
MONEY_REQUEST_CONFIRMATION: {
route: ':iouType/new/confirmation/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/confirmation/${reportID}` as const,
},
MONEY_REQUEST_DATE: {
route: ':iouType/new/date/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/date/${reportID}` as const,
},
MONEY_REQUEST_CURRENCY: {
route: ':iouType/new/currency/:reportID?',
getRoute: (iouType: string, reportID: string, currency: string, backTo: string) => `${iouType}/new/currency/${reportID}?currency=${currency}&backTo=${backTo}` as const,
},
MONEY_REQUEST_DESCRIPTION: {
route: ':iouType/new/description/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/description/${reportID}` as const,
},
MONEY_REQUEST_CATEGORY: {
route: ':iouType/new/category/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/category/${reportID}` as const,
},
MONEY_REQUEST_TAG: {
route: ':iouType/new/tag/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/tag/${reportID}` as const,
},
MONEY_REQUEST_MERCHANT: {
route: ':iouType/new/merchant/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/merchant/${reportID}` as const,
},
MONEY_REQUEST_WAYPOINT: {
route: ':iouType/new/waypoint/:waypointIndex',
getRoute: (iouType: string, waypointIndex: number) => `${iouType}/new/waypoint/${waypointIndex}` as const,
},
MONEY_REQUEST_RECEIPT: {
route: ':iouType/new/receipt/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/receipt/${reportID}` as const,
},
MONEY_REQUEST_DISTANCE: {
route: ':iouType/new/address/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/address/${reportID}` as const,
},

[SCREENS.MONEY_REQUEST.ROOT]: {
path: ROUTES.MONEY_REQUEST.route,
exact: true,
screens: {
[SCREENS.MONEY_REQUEST.MANUAL_TAB]: {
path: ROUTES.MONEY_REQUEST_MANUAL_TAB,
exact: true,
},
[SCREENS.MONEY_REQUEST.SCAN_TAB]: {
path: ROUTES.MONEY_REQUEST_SCAN_TAB,
exact: true,
},
[SCREENS.MONEY_REQUEST.DISTANCE_TAB]: {
path: ROUTES.MONEY_REQUEST_DISTANCE_TAB.route,
exact: true,
},
},
},

<TopTab.Screen
name={CONST.TAB.MANUAL}
component={NewRequestAmountPage}
initialParams={{reportID, iouType}}
/>
<TopTab.Screen
name={CONST.TAB.SCAN}
component={ReceiptSelector}
initialParams={{reportID, iouType, pageIndex: 1}}
/>
{shouldDisplayDistanceRequest && (
<TopTab.Screen
name={CONST.TAB.DISTANCE}
component={NewDistanceRequestPage}
initialParams={{reportID, iouType}}
/>
)}

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:

Update the should show check to this:

shouldShow={!IOUUtils.isValidMoneyRequestType(iouType) || !isAllowedToCreateRequest || [CONST.IOU.TYPE.REQUEST, CONST.IOU.TYPE.SPLIT].includes(iouType)}

And get rid of this if block:

{iouType === CONST.IOU.TYPE.REQUEST || iouType === CONST.IOU.TYPE.SPLIT ? (
<OnyxTabNavigator
id={CONST.TAB.RECEIPT_TAB_ID}
selectedTab={props.selectedTab}
tabBar={({state, navigation, position}) => (
<TabSelector
state={state}
navigation={navigation}
position={position}
/>
)}
>
<TopTab.Screen
name={CONST.TAB.MANUAL}
component={NewRequestAmountPage}
initialParams={{reportID, iouType}}
/>
<TopTab.Screen
name={CONST.TAB.SCAN}
component={ReceiptSelector}
initialParams={{reportID, iouType, pageIndex: 1}}
/>
{shouldDisplayDistanceRequest && (
<TopTab.Screen
name={CONST.TAB.DISTANCE}
component={NewDistanceRequestPage}
initialParams={{reportID, iouType}}
/>
)}
</OnyxTabNavigator>
) : (

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.

@joekaufmanexpensify
Copy link
Contributor

Ah, actually I think we just fixed that here.

@joekaufmanexpensify
Copy link
Contributor

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
Copy link
Contributor

@barros001 $500 sent and contract ended!

@joekaufmanexpensify
Copy link
Contributor

Upwork job auto closed, so opened a new one to pay @Ollyws

@joekaufmanexpensify
Copy link
Contributor

@Ollyws offer sent for $500!

@Ollyws
Copy link
Contributor

Ollyws commented Dec 14, 2023

Accepted, thanks!

@joekaufmanexpensify
Copy link
Contributor

Paid! Closing as this is all set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

9 participants