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

[$500] Dev: Web - Console error occurs when clicking on a deleted or paid request money category URL #28318

Closed
1 of 6 tasks
kbecciv opened this issue Sep 27, 2023 · 57 comments
Closed
1 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@kbecciv
Copy link

kbecciv commented Sep 27, 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!


Action Performed:

  1. Go to the workspace expense room chat.
  2. Navigate to "Request money" > "Manual"
  3. Enter an amount and click on "Next"
  4. Select a category and send the request.
  5. Go to the sent request money detail page.
  6. Click on the Category and copy the URL, then send it.
  7. Delete the request money.
  8. Click on the sent URL for the deleted request money.

Expected Result:

No console error should appear when clicking on the URL for a deleted or paid request money category

Actual Result:

A console error occurs when clicking on a deleted or paid request money category URL

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: Dev 1.3.74-2
Reproducible in staging?: n
Reproducible in production?: n
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
Notes/Photos/Videos: Any additional supporting documentation

screen-recording-2023-09-26-at-122150-pm_MBRPYdoK.mp4

Expensify/Expensify Issue URL:
Issue reported by: @ayazhussain79
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1695713591802959

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01d64fca889407111a
  • Upwork Job ID: 1707045828508962816
  • Last Price Increase: 2023-09-27
@kbecciv kbecciv added the External Added to denote the issue can be worked on by a contributor label Sep 27, 2023
@melvin-bot melvin-bot bot changed the title Dev: Web - Console error occurs when clicking on a deleted or paid request money category URL [$500] Dev: Web - Console error occurs when clicking on a deleted or paid request money category URL Sep 27, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 27, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01d64fca889407111a

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

melvin-bot bot commented Sep 27, 2023

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

@melvin-bot melvin-bot bot added the Daily KSv2 label Sep 27, 2023
@hungvu193
Copy link
Contributor

hungvu193 commented Sep 27, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Dev: Web - Console error occurs when clicking on a deleted or paid request money category URL

What is the root cause of that problem?

We're checking for update here to dismiss the modal when a request is deleted or paid.

if (canEdit) {
return;
}
Navigation.isNavigationReady().then(() => {
Navigation.dismissModal();
});

However in the meantime while navigate is ready, we still can render other pages before our Navigation.dismissModal(); is called.

However it took 300ms for this timeout to be called, but the view is already unmounted due to our Navigation.dismissModal();

if (this.props.isFocused && this.props.autoFocus && this.textInput) {
setTimeout(() => {
this.textInput.focus();
}, CONST.ANIMATED_TRANSITION);
}

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

  1. We should create a timeoutID for our BaseOptionSelector here:
    if (this.props.isFocused && this.props.autoFocus && this.textInput) {
    setTimeout(() => {
    this.textInput.focus();
    }, CONST.ANIMATED_TRANSITION);
    }

And clear it in our componentWillUnmount function.

We can also do similar thing with this block of code

  1. Remove the useEffect that used to dismiss the modal. Add a new variable called isCurrentRequestSettled to check if the current request was already settled, if yes we should redirect user in request page.
const isCurrentRequestSettled = isSettled && (isAdmin || isRequestor);

    useEffect(() => {
        if (!isCurrentRequestSettled) { 
            return;
        }
        
        Navigation.isNavigationReady().then(() => {
            Navigation.dismissModal(report.reportID);
        });

    }, [isCurrentRequestSettled]);
  1. Update the condition of rendering other screen, use need to have canEdit true to edit the page, otherwise FullPageNotFound will be displayed.
    if (canEdit && fieldToEdit === CONST.EDIT_REQUEST_FIELD.DESCRIPTION) {
        return (
            <EditRequestDescriptionPage />
        );
    }

Or we can just early return the FullPageNotFoundView page with the shouldShow={!canEdit}.

What alternative solutions did you explore? (Optional)

In our EditRequestPage, we should add an early return, instead of return FullPageNotFound at the end, we can bring it first if we couldn't edit the route:

    if (!canEdit) {
        return <FullPageNotFoundView shouldShow />;
    }

or we just return null if we can't edit the route:

    if (!canEdit) {
        return null;
    }

@saranshbalyan-1234
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Getting error while editing category of deleted request.

What is the root cause of that problem?

<View style={[styles.flexRow, styles.alignItemsCenter]}>

Here this.props.option.icons is undefined which causes the error.

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

We can have default value as 0 if Here this.props.option.icons is undefined

What alternative solutions did you explore? (Optional)

N/A

@Youhy
Copy link

Youhy commented Sep 27, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Getting error while editing category of deleted request.

What is the root cause of that problem?

this.textInput is a ref which is not initialised by the time when the function is called, or component already unmounted when the timeOut is executed

App/src/components/OptionsSelector/BaseOptionsSelector.js

Lines 71 to 75 in [cf9ad20](https://github.com/Expensify/App/commit/cf9ad20a4545ec01b16f88f9c1a53a7488ca1b44)
 if (this.props.isFocused && this.props.autoFocus && this.textInput) { 
     setTimeout(() => { 
         this.textInput.focus(); 
     }, CONST.ANIMATED_TRANSITION); 
 }

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

Ref cycle should be initialised properly and should not rely on timeouts assuming that element will be accessible by the time timeout is fulfilled. The timeout execution depends on the amount of asynchronous code running in EventLoop already.

What alternative solutions did you explore? (Optional)

Early return in EditRequestPage instead of returning FullPageNotFound at the end can help also, but this is a hack to bypass the issue instead of fixing it

@melvin-bot
Copy link

melvin-bot bot commented Sep 27, 2023

📣 @Youhy! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@Youhy
Copy link

Youhy commented Sep 27, 2023

Contributor details
Your Expensify account email: youhy@tut.by
Upwork Profile Link: https://www.upwork.com/freelancers/~01d867cf0154cbd9ba

@melvin-bot
Copy link

melvin-bot bot commented Sep 27, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@fedirjh
Copy link
Contributor

fedirjh commented Sep 29, 2023

Thanks @hungvu193 for the proposal, it seems that we have the clear logic for the timeout in the BaseOptionsSelector, it looks this was missed during #25564

if (this.focusTimeout) {
clearTimeout(this.focusTimeout);
}

Happy to move forward with @hungvu193's proposal as it fixes the root cause.

🎀 👀 🎀 C+ reviewed


Thanks, @Youhy for the proposal, clearing the timeout is the ideal solution for this case.

@melvin-bot
Copy link

melvin-bot bot commented Sep 29, 2023

Triggered auto assignment to @iwiznia, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@fedirjh
Copy link
Contributor

fedirjh commented Sep 29, 2023

cc @iwiznia Seems like we haven’t assigned a BZ member for this bug.

@melvin-bot melvin-bot bot added the Overdue label Oct 2, 2023
@iwiznia
Copy link
Contributor

iwiznia commented Oct 2, 2023

A couple questions:

  1. How would the timeoutID work exactly?
  2. Looking at the error seems that the variable is null and thus why it is failing, can't we just check that this.textInput is not null?
  3. What happens after you click the link with the proposed fix? Does it not do anything at all? Because I think it should show the page not found page, but I don't think it will?

@melvin-bot melvin-bot bot removed the Overdue label Oct 2, 2023
@hungvu193
Copy link
Contributor

A couple questions:

  1. How would the timeoutID work exactly?

  2. Looking at the error seems that the variable is null and thus why it is failing, can't we just check that this.textInput is not null?

  3. What happens after you click the link with the proposed fix? Does it not do anything at all? Because I think it should show the page not found page, but I don't think it will?

  1. setTimeout returned a positive int and we can pass it to clearTimeout to cancel the timeout (we actually did it before, but recently when we added new setTimeout we forgot to clean it)
  2. I don't think checking this.textInput is a good idea since it didn't solved the root cause, the problem here is that we were trying to run a function from unmounted component.
  3. After proposing the fix it will do nothing (as we dismissNavigation in our useEffect), but we can improve that.

@fedirjh
Copy link
Contributor

fedirjh commented Oct 2, 2023

How would the timeoutID work exactly?

It will simply be a reference that holds the timeout ID. We will use this reference to clear the timeout when the component unmounts. We already have the clear logic in this line

this.focusTimeout = setTimeout(...)

Looking at the error seems that the variable is null and thus why it is failing, can't we just check that this.textInput is not null?

Yes, that is expected. We didn't clear the timeout, and it will be executed after the component unmounts. Consequently, the input reference will be null at that time. So, it's ideal to clear the timeout rather than adding a safety check.

but I don't think it will?

Yes, that is currently the behavior. Should we consider updating it to display a "not found" view?

@iwiznia
Copy link
Contributor

iwiznia commented Oct 2, 2023

Thanks for clarifying! And yes, I think having a link that does absolutely nothing is as broken as the current behavior from a user perspective.

@hungvu193
Copy link
Contributor

So do we need to show the Not found page in this case?

@iwiznia iwiznia added the Bug Something is broken. Auto assigns a BugZero manager. label Oct 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 3, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 3, 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

@iwiznia
Copy link
Contributor

iwiznia commented Oct 3, 2023

I think we should, @greg-schroeder what do you think?

@greg-schroeder
Copy link
Contributor

We should definitely not have a link that does nothing - that's just the same buggy user experienced repackaged. I think we should show the not found page for sure

@greg-schroeder
Copy link
Contributor

Seems the slack discussion ended with:

"So if the user that submitted the request visits the edit page of a settled request, they would land (or get redirected) to the request page with all fields disabled"

@melvin-bot melvin-bot bot removed the Overdue label Oct 16, 2023
@hungvu193
Copy link
Contributor

hungvu193 commented Oct 17, 2023

Cool. Update my proposal to match the expected result:

  • If request is settled, redirect user to request page.
  • If user don't have edit permission, FullPageNotFound will be displayed.
Result
Screen.Recording.2023-10-17.at.22.22.12.mov

@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

@iwiznia @greg-schroeder @fedirjh this issue is now 3 weeks old. There is one more week left before this issue breaks WAQ and will need to go internal. What needs to happen to get a PR in review this week? Please create a thread in #expensify-open-source to discuss. Thanks!

@fedirjh
Copy link
Contributor

fedirjh commented Oct 18, 2023

Let's hold until #29101 is merged.

@greg-schroeder greg-schroeder added Weekly KSv2 and removed Daily KSv2 labels Oct 19, 2023
@greg-schroeder greg-schroeder changed the title [$500] Dev: Web - Console error occurs when clicking on a deleted or paid request money category URL [Hold for PR #29101] [$500] Dev: Web - Console error occurs when clicking on a deleted or paid request money category URL Oct 19, 2023
@hungvu193
Copy link
Contributor

Looks like #29101 is now merged

@hungvu193
Copy link
Contributor

now merchant and description can be updated when a request is paid, is this expected?

@melvin-bot melvin-bot bot added the Overdue label Oct 27, 2023
@greg-schroeder
Copy link
Contributor

What do you think @fedirjh?

@melvin-bot melvin-bot bot removed the Overdue label Oct 27, 2023
@fedirjh
Copy link
Contributor

fedirjh commented Oct 27, 2023

now merchant and description can be updated when a request is paid, is this expected?

This is the expected behavior:

  1. IOU: No edits allowed after request is settled.
  2. Expense Reports:
    • Members (requester): No edits allowed after request is settled.
    • Admins: Can edit any field except : amount, currency, date, distance and receipt, after the request is settled

What do you think

@greg-schroeder Let's remove the hold. I am not sure what we will be fixing in this issue. Another PR fixed the original issue that was reported. So I think we should just close this issue.

@hungvu193
Copy link
Contributor

When clicking edit date deeplink still nothing happens. Isn't that we're fixing in this issue?

@fedirjh
Copy link
Contributor

fedirjh commented Oct 30, 2023

When clicking edit date deeplink still nothing happens. Isn't that we're fixing in this issue?

@hungvu193 As per this thread: https://expensify.slack.com/archives/C01GTK53T8Q/p1697137352110949?thread_ts=1697134708.508379&cid=C01GTK53T8Q , I think that's expected behavior.

@melvin-bot melvin-bot bot added the Overdue label Nov 8, 2023
@greg-schroeder greg-schroeder changed the title [Hold for PR #29101] [$500] Dev: Web - Console error occurs when clicking on a deleted or paid request money category URL [$500] Dev: Web - Console error occurs when clicking on a deleted or paid request money category URL Nov 9, 2023
@greg-schroeder greg-schroeder added Daily KSv2 and removed Weekly KSv2 Overdue labels Nov 9, 2023
@greg-schroeder
Copy link
Contributor

Removed hold, sorry for delay I missed this one

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Nov 9, 2023
@greg-schroeder
Copy link
Contributor

I think we should just close this after reviewing more. Please comment if you disagree.

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 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

8 participants