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 2024-04-05] Android - Chat - When offline, if a user requests money and then deletes the message, the page keeps loading #38844

Closed
1 of 6 tasks
kbecciv opened this issue Mar 22, 2024 · 16 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Engineering Weekly KSv2

Comments

@kbecciv
Copy link

kbecciv commented Mar 22, 2024

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.56.0
Reproducible in staging?: y
Reproducible in production?: n
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4447619
Issue reported by: Applause - Internal Team

Action Performed:

  1. Launch app
  2. Tap on a new 1:1 report
  3. Go offline
  4. Send a message
  5. Delete the message
  6. Note the message is striked and no skeleton loading in the page
  7. Tap plus icon and request money
  8. Complete the request money flow
  9. Send a message
  10. Delete the message
  11. Now note the page behaviour

Expected Result:

When offline, after requesting money, if a user sends and deletes a message, the deleted message should be struck through, and the rest of the messages on the page should display without any issues.

Actual Result:

When offline, after requesting money, if a user sends and deletes a message, the deleted message is struck through. However, the above messages and the entire page keep loading, displaying a skeleton.

Workaround:

n/a

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

Add any screenshot/video evidence

Bug6423554_1711133956935.chin.mp4

View all open jobs on GitHub

@kbecciv kbecciv added the DeployBlockerCash This issue or pull request should block deployment label Mar 22, 2024
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

Copy link

melvin-bot bot commented Mar 22, 2024

Triggered auto assignment to @NikkiWines (Engineering), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

@kbecciv
Copy link
Author

kbecciv commented Mar 22, 2024

We think that this bug might be related to #vip-vsb

@NikkiWines
Copy link
Contributor

NikkiWines commented Mar 23, 2024

When testing on dev, this behavior is reproducible for me on web as well. @kbecciv can you confirm if this is specific to Android or a regression across all platforms?

@NikkiWines
Copy link
Contributor

I have a suspicion that this is tied to the changes added by #30269. It also seems like similar behavior to another existing blocker #38781.

@roryabraham looks like you have context for both the PR and the associated blocker, thoughts?

@roryabraham
Copy link
Contributor

Yeah, looks quite possibly like the same root cause. Let's CP and retest.

@bernhardoj
Copy link
Contributor

bernhardoj commented Mar 23, 2024

Proposal

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

The other messages disappear and the skeleton shows when deleting a message.

What is the root cause of that problem?

The other messages disappear because getContinuousReportActionChain only includes some of the messages.

return sortedReportActions.slice(startIndex, endIndex + 1);
}

When calculating the endIndex, we check whether the current action previousReportActionID is the same as the previous action previousReportActionID.

while (
(endIndex < sortedReportActions.length - 1 && sortedReportActions[endIndex].previousReportActionID === sortedReportActions[endIndex + 1].reportActionID) ||
!!sortedReportActions[endIndex + 1]?.whisperedToAccountIDs?.length ||
!!sortedReportActions[endIndex]?.whisperedToAccountIDs?.length ||
sortedReportActions[endIndex]?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM ||
sortedReportActions[endIndex + 1]?.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED ||
sortedReportActions[endIndex + 1]?.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED
) {
endIndex++;
}

However, a newly optimistic added action doesn't have previousReportActionID yet, so the condition always fails.

The initial value of endIndex (and startIndex) is calculated here by finding the index of the action that the pendingAction value is not add,

index = sortedReportActions.findIndex((obj) => obj.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD);

and because we delete the first action, the pending action is updated to delete, so the endIndex value is 0.

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

Based on this comment, the reason we check for pending action add is that the action doesn't have the previousReportActionID value yet which we rely on the BE to give us the value.

// 2. If the first condition fails, it then checks if the previous item has a pendingAction of 'add'.
// This additional check is to include recently sent messages that might not yet be part of the established sequence.

But as mentioned above, when deleting the message, the pending action value is overwritten. The cause of the issue is the same as this one where we rely on the pending action, but it's overwritten. To overcome the issue, we introduce a new property called isOptimisticAction.

So, the solution is to replace the pending action check with isOptimisticAction.
Sorry, we shouldn't replace it but rather add another check for isOptimisticAction.

index = sortedReportActions.findIndex((obj) => obj.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD);

index = sortedReportActions.findIndex((obj) => ... || !obj.isOptimisticAction);

sortedReportActions[startIndex - 1]?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD ||

... ||
sortedReportActions[startIndex - 1]?.isOptimisticAction

What alternative solutions did you explore? (Optional)

Optimistically set previousReportActionID to a new action, but doesn't sound good because it's possible the action list is not in order when the app is still loading or while offline.

@bernhardoj
Copy link
Contributor

The issue still happens, please check my proposal for the solution.

@roryabraham
Copy link
Contributor

@bernhardoj I like your alternate solution better - it seems like optimistic actions could be seamlessly integrated into the chain by setting the previousReportActionID to be the ID of the newest action on a report whenever creating a new one optimistically.

@melvin-bot melvin-bot bot added the Overdue label Mar 25, 2024
@roryabraham
Copy link
Contributor

doesn't sound good because it's possible the action list is not in order when the app is still loading or while offline

Not sure I'm following the concern here @bernhardoj

@roryabraham
Copy link
Contributor

This will be fixed by #38968. I do think including previousReportActionID in optimistic actions is a better solution, but too big a refactor to CP

@bernhardoj
Copy link
Contributor

bernhardoj commented Mar 26, 2024

Not sure I'm following the concern here @bernhardoj

So, I'm thinking of 2 cases where the optimistic previousReportActionID could be wrong.

  1. When you open a chat that the report actions are not loaded yet (empty, 0 length). In this case, the first optimistic comment previousReportActionID would be empty.
  2. When you open a chat that has incomplete/outdated report actions

EDIT: Btw, do we really to check for the DELETE pending action too? I think the reason we check for ADD pending action is because the action doesn't have previousReportActionID yet, but the pending action may be overwritten with either DELETE or UPDATE, so we need to rely on isOptimisticAction too.

EDIT 2: I just remember isOptimisticAction is currently only available when adding a message/attachment and task, so we may need to add isOptimisticAction for other user-generated actions that can be deleted, such as money requests (I think money request is the only one left).

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Hourly KSv2 labels Mar 26, 2024
@roryabraham roryabraham added Hourly KSv2 and removed Weekly KSv2 labels Mar 26, 2024
@roryabraham
Copy link
Contributor

When you open a chat that the report actions are not loaded yet (empty, 0 length). In this case, the first optimistic comment previousReportActionID would be empty

That's actually a very good point

@roryabraham
Copy link
Contributor

verified that this is fixed on staging, going to close it out now.

@roryabraham roryabraham removed the DeployBlockerCash This issue or pull request should block deployment label Mar 26, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Hourly KSv2 labels Mar 29, 2024
@melvin-bot melvin-bot bot changed the title Android - Chat - When offline, if a user requests money and then deletes the message, the page keeps loading [HOLD for payment 2024-04-05] Android - Chat - When offline, if a user requests money and then deletes the message, the page keeps loading Mar 29, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Mar 29, 2024
Copy link

melvin-bot bot commented Mar 29, 2024

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

Copy link

melvin-bot bot commented Mar 29, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.57-5 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 2024-04-05. 🎊

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 Engineering Weekly KSv2
Projects
None yet
Development

No branches or pull requests

4 participants