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 for payment 2023-12-08] [$1000] Web - App does not display working report on back from 'something is wrong page' #23068

Closed
1 of 6 tasks
kbecciv opened this issue Jul 18, 2023 · 170 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production 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

Comments

@kbecciv
Copy link

kbecciv commented Jul 18, 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. Open the app
  2. Open any report, to trigger something is wrong page, send any attachment, click on attachment and copy URL, send URL, delete the attachment and click on URL
  3. Click on browser back, observe that it changes URL but it still displays something is wrong page
  4. Reload and observe that app now displays proper report

Expected Result:

App should display chat report on back from 'something is wrong' page if report don't have any issue

Actual Result:

App still displays 'something is wrong' page on browser back click even though app changes URL to a working report

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: 1.3.41-2
Reproducible in staging?: y
Reproducible in production?: y
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

something.is.wrong.back.button.wrong.working.mp4
Recording.3714.mp4

Expensify/Expensify Issue URL:
Issue reported by: @dhanashree-sawant
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1689531247187909

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01f4efb0d0e28187e6
  • Upwork Job ID: 1682055964789444608
  • Last Price Increase: 2023-11-20
  • Automatic offers:
    • 0xmiroslav | Reviewer | 27774673
    • WikusKriek | Contributor | 27774676
    • dhanashree-sawant | Reporter | 27774677
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 18, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 18, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 18, 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

@DanutGavrus
Copy link
Contributor

DanutGavrus commented Jul 18, 2023

Proposal

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

App does not display working report on back from 'something is wrong page'

What is the root cause of that problem?

  1. We throw an error if we don't find the attachment:
    const page = _.findIndex(attachments, (a) => a.source === this.props.source);
    if (page === -1) {
    throw new Error('Attachment not found');
    }
  2. We never clear that error, so pressing on the back button, still shows the Error page.

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

To fix 1st problem:

Instead of throwing an error, we could show the FullPageNotFoundView, and optionally, we could add a `Log` and a new text in our languages to show a custom error.

if (page === -1) {
    Log.warn('Attachment not found'); // Optional
    return {
        attachmentNotFound: true,
    }
}
<FullPageNotFoundView
  shouldShow={this.state.attachmentNotFound}
  subtitleKey='notFound.attachmentYouLookingForCannotBeFound' // Optional
  >
  <View

Add to en.js file(Optional, we'll also need the Spanish translation):

notFound: {
  attachmentYouLookingForCannotBeFound: 'The attachment you are looking for cannot be found.',

To fix 2nd problem:

Inside BaseErrorBoundary component, add the componentDidMount method which is not yet present. In it, we'll add a listener which clears the existing error when user presses on the back button(if it exists):

componentDidMount() {
    window.onpopstate = () => {
        if (this.state.hasError) {
            this.clearError();
        }
    }
}

Adding the listener in the componentDidMount method will not flash the page when user presses on the back button.

@melvin-bot melvin-bot bot added the Overdue label Jul 20, 2023
@michaelhaxhiu
Copy link
Contributor

This is a very edge case bug, but it is indeed "inconsistent" from the behavior we'd expect in the app. I think we should try to fix it (and hopefully it's not a big undertaking to do so).

@melvin-bot melvin-bot bot removed the Overdue label Jul 20, 2023
@michaelhaxhiu michaelhaxhiu added External Added to denote the issue can be worked on by a contributor Overdue labels Jul 20, 2023
@melvin-bot melvin-bot bot changed the title Web - App does not display working report on back from 'something is wrong page' [$1000] Web - App does not display working report on back from 'something is wrong page' Jul 20, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 20, 2023

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

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

melvin-bot bot commented Jul 20, 2023

Current assignee @michaelhaxhiu is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Jul 20, 2023

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

@rk111
Copy link

rk111 commented Jul 22, 2023

Hi,
Assign to me I will work in this

@kameshwarnayak
Copy link
Contributor

kameshwarnayak commented Jul 22, 2023

Proposal

Edited to address 2 issues as per this comment #23068 (comment)

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

Bug 1: Infinite loading shows when you open not available/inaccessible attachments (Point 5 in the above comment)
Bug 2: App redirects to not accessible chat (Point 7 in the above comment)

What is the root cause of that problem?

Bug 1: Infinite loading shows when you open not available/inaccessible attachments (Point 5 in the above comment)

We are not handling onError/onLoadEnd in the ImageView. isLoading is set to true in onLoadStart={imageLoadingStart}. However isLoading is reset to false in onLoad={imageLoad} which doesn't get called since the image is not loaded. This causes infinite loading error.

<Image
source={{uri: url}}
isAuthTokenRequired={isAuthTokenRequired}
style={[styles.h100, styles.w100]}
resizeMode={Image.resizeMode.contain}
onLoadStart={imageLoadingStart}
onLoad={imageLoad}
/>

Bug 2: App redirects to not accessible chat (Point 7 in the above comment)

Root cause of this bug is that when the AttachmentModal is closed, we call Navigation.dismissModal.

In Navigation.dismissModal, if the targetReportID is not same as the one on top of the stack, we replace the URL with the URL of the targetReportID

onModalHide={() => Navigation.dismissModal(reportID)}

if (targetReportID && targetReportID !== getTopmostReportId(rootState)) {
const state = getStateFromPath(ROUTES.getReportRoute(targetReportID));
const action = getActionFromState(state, linkingConfig.config);
action.type = 'REPLACE';
navigationRef.current.dispatch(action);

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

To solve Bug 1 we need to write an handler for onError/onLoadEnd for Image component.

  1. Define a state variable error
    const [error, setError] = useState(false);
  2. Define function onError to set error and remove loading
    const onError = (e) =>{
        setError(true);
        setIsLoading(false);
    }
  1. Set onError handler in the Image component and If error is true show a BlockingView
{error === true ? (
    <BlockingView
        icon={Illustrations.ToddBehindCloud}
        iconWidth={variables.modalTopIconWidth}
        iconHeight={variables.modalTopIconHeight}
        title={translate('notFound.notHere')} 
    />
    ) : (
        <Image
            source={{uri: url}}
            isAuthTokenRequired={isAuthTokenRequired}
            // Hide image until finished loading to prevent showing preview with wrong dimensions.
            style={isLoading ? undefined : [styles.w100, styles.h100]}
            // When Image dimensions are lower than the container boundary(zoomscale <= 1), use `contain` to render the image with natural dimensions.
            // Both `center` and `contain` keeps the image centered on both x and y axis.
            resizeMode={zoomScale > 1 ? Image.resizeMode.center : Image.resizeMode.contain}
            onLoadStart={imageLoadingStart}
            onLoad={imageLoad}
            onError={onError}
        />
    )}

Result :

Screen.Recording.2023-09-04.at.6.27.10.PM.mov

To solve Bug 2 we can check for error and if there is any error in loading the image, open the report in the top of the Stack. We can achieve this by following the below steps

  1. Pass error param to Navigation.dismissModal
  2. If error is true, open the latest report
            if (!error && targetReportID && targetReportID !== getTopmostReportId(rootState)) {
  1. In ReportAttachment.js define a state variable error and pass the value to Navigation.dismissModal
    const [error, setError] = useState(false);

    return (
        <AttachmentModal
            ...
            onError={setError}
            onModalHide={() => Navigation.dismissModal(reportID, error)}
            ...
        />
  1. onError handler is passed to the children components and is called when there is an error in loading an image

Result :

Redirect.mov

What alternative solutions did you explore? (Optional)

None

@melvin-bot melvin-bot bot added the Overdue label Jul 24, 2023
@rk111
Copy link

rk111 commented Jul 24, 2023

Proposal

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

The problem we are trying to solve is that the app does not display the working report when the user navigates back from the "Something is wrong" page.

What is the root cause of that problem?

The root cause of this problem is that in the AttachmentCarousel component, when the app doesn't find the expected attachment, it throws an error. This error prevents the app from displaying the working report, leaving the user stuck on the "Something is wrong" page.

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

To solve the problem, instead of throwing an error, we should handle the scenario where the attachment is not found in a more graceful manner. We can make the following changes:

In the AttachmentCarousel component, when the attachment is not found, set a state flag (e.g., "attachmentNotFound") to true, indicating that the attachment is not available.

Rather than throwing an error, we should return from the function to allow the app to continue executing without interruption.

Show the FullPageNotFoundView component with a custom error message when the "attachmentNotFound" flag is true.

Optional Changes:

Log a warning (using Log.warn) when the attachment is not found, which can be helpful for debugging purposes.

Add a new text key in the language files (e.g., en.js and possibly in Spanish translation as well) to display a custom error message when the attachment is not found.

// Inside AttachmentCarousel class

constructor(props) {
    super(props);
    this.state = {
        attachmentNotFound: false,
    };
}

// Inside the function where the attachment is not found

const page = _.findIndex(attachments, (a) => a.source === this.props.source);
if (page === -1) {
    Log.warn('Attachment not found'); // Optional
    this.setState({ attachmentNotFound: true });
    return;
}

// Render method

render() {
    // ...
    return (
        <>
            {this.state.attachmentNotFound && (
                <FullPageNotFoundView
                    shouldShow={true}
                    subtitleKey='notFound.attachmentYouLookingForCannotBeFound' // Optional, provide the language key
                />
            )}
            <View
                // Render the AttachmentCarousel content here
            />
        </>
    );
}

@greg-schroeder
Copy link
Contributor

For C+ (@0xmiroslav) - can you confirm if any solutions in this issue may apply to #23374?

@melvin-bot
Copy link

melvin-bot bot commented Jul 25, 2023

@michaelhaxhiu, @0xmiroslav Huh... This is 4 days overdue. Who can take care of this?

@michaelhaxhiu
Copy link
Contributor

DM'ed miki to make sure he's aware of this one. We can re-assign to another C+ if you are busy too!

@melvin-bot melvin-bot bot removed the Overdue label Jul 27, 2023
@0xmiroslav
Copy link
Contributor

For C+ (@0xmiroslav) - can you confirm if any solutions in this issue may apply to #23374?

@greg-schroeder I followed repro step in #23374. First time, it shows infinite loading and from next time, it crashes which is this GH.
So I suggest to put #23374 on hold for this.

@0xmiroslav
Copy link
Contributor

Page not found view looks good to me but it's new design pattern to show it in preview modal, not in full screen.

@shawnborton do you think it's fine? (Here, back arrow button should be removed of course)

Screenshot 2023-07-27 at 3 48 44 PM

@melvin-bot
Copy link

melvin-bot bot commented Jul 27, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Dec 1, 2023
Copy link

melvin-bot bot commented Dec 1, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Dec 1, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.6-2 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-12-08. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Dec 1, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@0xmiroslav] The PR that introduced the bug has been identified. Link to the PR:
  • [@0xmiroslav] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@0xmiroslav] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@0xmiroslav] Determine if we should create a regression test for this bug.
  • [@0xmiroslav] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@sonialiap / @dylanexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@dylanexpensify
Copy link
Contributor

payment upcoming!

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Dec 8, 2023
@dylanexpensify
Copy link
Contributor

Payment summary:

Please apply!

@melvin-bot melvin-bot bot removed the Overdue label Dec 11, 2023
@dylanexpensify
Copy link
Contributor

@dhanashree-sawant still waiting for you to accept!

@dylanexpensify
Copy link
Contributor

@WikusKriek paid!
@0xmiroslav paid! Mind doing checklist?

@dylanexpensify
Copy link
Contributor

bump @0xmiroslav 🙇‍♂️

@dhanashree-sawant
Copy link

Hi @dylanexpensify, sorry for the delay, we already have accepted offer for the job sent before in november, I have messaged you on upwork in that job, can you approve that?

@melvin-bot melvin-bot bot added the Overdue label Dec 15, 2023
Copy link

melvin-bot bot commented Dec 18, 2023

@sonialiap, @jasperhuangg, @WikusKriek, @dylanexpensify, @0xmiroslav Huh... This is 4 days overdue. Who can take care of this?

@dylanexpensify
Copy link
Contributor

approving today!

@melvin-bot melvin-bot bot removed the Overdue label Dec 20, 2023
@0xmiroslav
Copy link
Contributor

Regression Test Proposal

  1. Send any attachment to any chat
  2. View the attachment
  3. Copy the URL
  4. Paste that URL in another chat
  5. Click on the URL to open the attachment preview
  6. Close preview
  7. Verify that it keeps the same chat you were on when opening the attachment, not redirecting to the report of the attachment

@dylanexpensify
Copy link
Contributor

@dhanashree-sawant it doesn't show either accepted, can you just accept the new one?

@dylanexpensify
Copy link
Contributor

bump @dhanashree-sawant

@melvin-bot melvin-bot bot added the Overdue label Dec 25, 2023
Copy link

melvin-bot bot commented Dec 26, 2023

@sonialiap, @jasperhuangg, @WikusKriek, @dylanexpensify, @0xmiroslav Whoops! This issue is 2 days overdue. Let's get this updated quick!

@dhanashree-sawant
Copy link

So sorry for the delay, I was away for a week, the new offer too expired 😅, can you provide a new offer whenever you are available?

Copy link

melvin-bot bot commented Dec 28, 2023

@sonialiap, @jasperhuangg, @WikusKriek, @dylanexpensify, @0xmiroslav Eep! 4 days overdue now. Issues have feelings too...

@sonialiap
Copy link
Contributor

@dhanashree-sawant new offer sent :)

@melvin-bot melvin-bot bot removed the Overdue label Dec 29, 2023
@dhanashree-sawant
Copy link

Thanks @sonialiap, I have accepted the offer.

@sonialiap
Copy link
Contributor

Payment completed 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production 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
Projects
None yet
Development

No branches or pull requests