App icon indicating copy to clipboard operation
App copied to clipboard

[$250] WS Chat – Blank page opens when go back from IOU thread in a Collect WS chat

Open lanitochka17 opened this issue 10 months ago • 10 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.65-4 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/
  2. Log in as Collect WS Employee
  3. In a WS chat create a Submit expense
  4. Open just created Submit expense
  5. Navigate back to WS chat via header link

Expected Result:

Collect WS chat with history opens

Actual Result:

Blank page opens when go back from IOU thread in a Collect WS chat

Workaround:

Unknown

Platforms:

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

  • [x] Android: Native
  • [x] Android: mWeb Chrome
  • [ ] iOS: Native
  • [ ] iOS: mWeb Safari
  • [x] MacOS: Chrome / Safari
  • [ ] MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/Expensify/App/assets/78819774/ca52fdf6-bcf5-400d-be4a-ff4a86d269a2

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01dee105cffad79099
  • Upwork Job ID: 1783269604755496960
  • Last Price Increase: 2024-04-24

lanitochka17 avatar Apr 24 '24 19:04 lanitochka17

Triggered auto assignment to @sakluger (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

melvin-bot[bot] avatar Apr 24 '24 19:04 melvin-bot[bot]

@sakluger FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

lanitochka17 avatar Apr 24 '24 19:04 lanitochka17

We think that this bug might be related to #wave-collect - Release 1

lanitochka17 avatar Apr 24 '24 19:04 lanitochka17

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

melvin-bot[bot] avatar Apr 24 '24 22:04 melvin-bot[bot]

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

melvin-bot[bot] avatar Apr 24 '24 22:04 melvin-bot[bot]

Cannot reproduce...

https://github.com/Expensify/App/assets/48998844/7dfd5b53-8593-4022-91da-538cc2cb85b5

beodw avatar Apr 25 '24 00:04 beodw

Proposal

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

WS Chat – Blank page opens when go back from IOU thread in a Collect WS chat

What is the root cause of that problem?

https://github.com/Expensify/App/blob/0f39e4370ccd84ccf7e1647b42cb505a69a2e9a3/src/pages/home/report/ReportActionsView.tsx#L164-L182

The issue is that when the network is slow, loading is set to true, and then when the page switches, loading remains true, resulting in an empty array being returned. If the page is not refreshed, loading will remain blank, waiting for the response to return.

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

remove condition isLoading in Line 169 if not effect another PR. As your comment suggests, even if loading, it shouldn't be blank, should use data what we had. Therefore, I suggest removing it here.

What alternative solutions did you explore? (Optional)

N/A

charles-liang avatar Apr 25 '24 03:04 charles-liang

Reproduce method is turn on slow network, like chrome network or emulator setting

charles-liang avatar Apr 25 '24 03:04 charles-liang

Proposal

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

Collect WS Chat – Blank page opens when go back from IOU thread in a Collect WS chat

What is the root cause of that problem?

The reportsActions array is temporarily empty in the ReportActionsView while loading new report data on slow connections. This is because it takes a while for the response to be received from the backend and within the reportActionView component we set reportActions to an empty array while loading.

const reportActions = useMemo(() => {
        if (!reportActionID) {
            return combinedReportActions;
        }
        if (isLoading || indexOfLinkedAction === -1) {
            return [];
        }

        if (isFirstLinkedActionRender.current) {
            return combinedReportActions.slice(indexOfLinkedAction);
        }
        const paginationSize = getInitialPaginationSize;
        return combinedReportActions.slice(Math.max(indexOfLinkedAction - paginationSize, 0));

        // currentReportActionID is needed to trigger batching once the report action has been positioned
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [reportActionID, combinedReportActions, indexOfLinkedAction, isLoading, currentReportActionID]);

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

In the reportsActionsView component we can return a skeleton loader instead of null when the reportActions array is temporarily empty.

In ReportsActionsView.tsx:

if (!reportActions.length) {
        return null;
    }

Changes to:

if (!reportActions.length) {
        return <ReportActionsSkeletonView />;
    }

What alternative solutions did you explore? (Optional)

None

https://github.com/Expensify/App/assets/48998844/9e09229e-ddae-4272-acec-de95312695c0

beodw avatar Apr 25 '24 16:04 beodw

@jjcoffee @sakluger Hi guys, kindly following up on whether this issue has been resolved. If not, please kindly let me know when you will have the capacity to review it. Cheers!

beodw avatar Apr 28 '24 16:04 beodw

@beodw Thanks for the proposal!

I think the expected result here is probably not to show a loader, as we actually already have all the data we need. It looks like there's something specifically wrong with loading via the route that highlights the expense's reportAction, i.e. /r/{reportID}/{reportActionID}. If you omit the latter part, it loads immediately as expected (regardless of connection speed).

https://github.com/Expensify/App/assets/27287420/aa089042-5465-48e7-8a4a-0c8f3e52de91

jjcoffee avatar Apr 29 '24 09:04 jjcoffee

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

melvin-bot[bot] avatar May 01 '24 16:05 melvin-bot[bot]

@beodw @charles-liang do you have any updated proposals based on @jjcoffee's comment?

sakluger avatar May 01 '24 19:05 sakluger

@sakluger

I don't know if they didn't read my proposal, or if I wasn't clear. I suggested using a cache from the previous, to store the data. Then, when we return, reload it, and then asynchronously refresh the network data. Isn't this the same as @jjcoffee comment?

charles-liang avatar May 02 '24 01:05 charles-liang

@charles-liang Apologies for not giving feedback on your proposal. We don't need to implement caching as such. You can see from the issue's video that tapping on the report directly loads it just fine (as I also point out here).

jjcoffee avatar May 02 '24 13:05 jjcoffee

@jjcoffee I'm also apology that I miss understand your comment.

charles-liang avatar May 02 '24 15:05 charles-liang

Proposal

Updated

charles-liang avatar May 04 '24 09:05 charles-liang

remove condition isLoading in Line 169 if not effect another PR

@charles-liang Generally it's best to know in advance if the solution would cause a regression. In this case it seems highly likely that this would stop the loader from showing in cases where we want it to show.

jjcoffee avatar May 06 '24 12:05 jjcoffee

Just a heads up I'll be OOO 6-13th, so feel free to re-assign if proposals start rolling in before I'm back!

jjcoffee avatar May 06 '24 12:05 jjcoffee

@jjcoffee I reviewed the commit history, and it was introduced in this commit. Before this, the reportActions data would not return empty due to other influences.

https://github.com/Expensify/App/blob/f306f4b585b5f73674685309c44add9c3a9d7f36/src/pages/home/ReportScreen.tsx#L264-L270

https://github.com/Expensify/App/blob/f306f4b585b5f73674685309c44add9c3a9d7f36/src/pages/home/ReportScreen.tsx#L550-L559

Moreover,

  1. enabling the loading skeleton is on ReportScreen not in ReportActionsView

https://github.com/Expensify/App/blob/c496ce653943934f6a47bae2fcf520ae08c69743/src/pages/home/ReportScreen.tsx#L715

  1. loading new data from network in the background is also from ReportScreen

Therefore, I conclude that this loading condition is unnecessary and will not impact other PRs.

charles-liang avatar May 06 '24 14:05 charles-liang

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

melvin-bot[bot] avatar May 08 '24 16:05 melvin-bot[bot]

@sakluger @jjcoffee this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

melvin-bot[bot] avatar May 08 '24 18:05 melvin-bot[bot]

@sakluger, @jjcoffee Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

melvin-bot[bot] avatar May 09 '24 18:05 melvin-bot[bot]

Reassigning C+ since JJ is out until next week.

sakluger avatar May 10 '24 04:05 sakluger

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

melvin-bot[bot] avatar May 10 '24 04:05 melvin-bot[bot]

@thesahindia FYI we have an updated proposal from @charles-liang here.

sakluger avatar May 10 '24 04:05 sakluger

Proposal

Workspace expense chat becomes blank page when go back from IOU / transaction thread.

What is the root cause of that problem?

Essentially, there are three reports involved:

  1. Workspace Expense Report: This report contains an expense preview with text (e.g., displaying 8 expenses).

  2. Report with Multiple Expense Request Previews: This report features several expense request previews.

  3. Transaction Details Thread Report: This report is accessed from an expense preview in the second report.

Precondition: You need to open these three reports before testing this bug.

The issue occurs when a user submits an expense from the first report. The flow is as follows:

  • The user submits an expense from the first report, triggering a MoneyRequest API request.
  • Opening the second report by clicking on an expense preview (which includes text such as "8 expenses") triggers an OpenReport API request for the second report.
  • Clicking on any expense preview within the second report opens the third report.
  • Returning to the second report from the third report by clicking on the header link in the third report.

The problem arises because the OpenReport process initiated in the second step has not yet completed. This delay occurs because the OpenReport is waiting for the MoneyRequest to finish, while isLoadingInitialReportActions is set to true for the second report. Consequently, isLoading remains true due to the presence of a reportActionID in the route:

https://github.com/Expensify/App/blob/bc3009a97dfb9eba4127e182c7703564166ba4c9/src/pages/home/report/ReportActionsView.tsx#L122

Which will make the reportActions to be empty:

https://github.com/Expensify/App/blob/2a6d63d7f17b1e4fba94f26103f13c6afe294b91/src/pages/home/report/ReportActionsView.tsx#L165-L167

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

Here:

https://github.com/Expensify/App/blob/bc3009a97dfb9eba4127e182c7703564166ba4c9/src/pages/home/report/ReportActionsView.tsx#L122

The isLoading check should be updated to:

const isLoading = !!reportActionID && isLoadingInitialReportActions && !isReadyForCommentLinking;

Change the || comparison to && because the value of isReadyForCommentLinking determines if a cached linked report action is available. Therefore, isLoading should only be true when the cached linked report action does not exist in Onyx.

The display of the skeleton is controlled in ReportScreen.tsx. Thus, changing the || to && here is appropriate.

Another solution is to include the hasMoreCached condition in isLoading. Move the declaration of isLoading below hasMoreCached and modify the line to:

const isLoading = (!!reportActionID && isLoadingInitialReportActions && !hasMoreCached) || !isReadyForCommentLinking;

The issue where the report only displays report actions from linked report actions and older ones is because

https://github.com/Expensify/App/blob/198b47360fa6fa5bfbb81f3fb535a2fa6817e375/src/pages/home/report/ReportActionsView.tsx#L345-L355

When isLoadingInitialReportActions is true, loadNewerChats will early return and not display newer chats.

To immediately display the preview of newer cached report actions, include a check there:

Modify it to (isLoadingInitialReportActions && !hasMoreCached) || to enable loading the preview of newer cached report actions.


Regarding:

I have applied the second change, but now once OpenReport completes, the report preview jumps to the bottom and all following messages/report previews are removed.

This occurs because:

https://github.com/Expensify/App/blob/60530f643b30f30510914ed28e2a90ed5d37184a/src/pages/home/report/ReportActionsView.tsx#L150-L155

We set isFirstLinkedActionRender.current = true; when isLoadingInitialReportActions changes (in this case, when OpenReport completes). Consequently, report actions are sliced from the linked report action to older messages:

https://github.com/Expensify/App/blob/60530f643b30f30510914ed28e2a90ed5d37184a/src/pages/home/report/ReportActionsView.tsx#L187-L189

Resulting in the removal of newer report actions.

To address this, we should remove the dependency on isLoadingInitialReportActions in useEffect. Alternatively, we could depend only on [reportID, reportActionID]. This constitutes the third change. I hope this resolves any issues.

tsa321 avatar May 12 '24 09:05 tsa321

@sakluger, @thesahindia Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

melvin-bot[bot] avatar May 13 '24 19:05 melvin-bot[bot]

@sakluger Happy to take this one back if @thesahindia is too busy!

jjcoffee avatar May 14 '24 10:05 jjcoffee

Thanks @jjcoffee! I've assigned it back to you.

sakluger avatar May 14 '24 11:05 sakluger