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-01-26] [$500] Settings - Red dot remains after error is cleared #33021

Closed
2 of 6 tasks
lanitochka17 opened this issue Dec 13, 2023 · 49 comments
Closed
2 of 6 tasks
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

@lanitochka17
Copy link

lanitochka17 commented Dec 13, 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.4.12-0
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
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Issue found when executing PR #31713

Action Performed:

Pre-requisite: user must be logged in

  1. On staging, enable "Simulate failing network requests" in Settings > Preferences
  2. Go to Settings > Profile > Contact method
  3. Add a phone number as a new contact method
  4. Wait for the pending add operation to fail
  5. Once you see the red dot, click on the contact method and clear the error

Expected Result:

The red dot should disappear after the error is cleared

Actual Result:

The red dot remains on user avatar on the home screen and in settings

Workaround:

Unknown

Platforms:

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

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

Screenshots/Videos

Add any screenshot/video evidence

Bug6312254_1702503451411.bandicam_2023-12-13_15-07-14-733.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~012ec660a67cb6d223
  • Upwork Job ID: 1735053356937179136
  • Last Price Increase: 2024-01-03
  • Automatic offers:
    • ntdiary | Reviewer | 28089273
    • tienifr | Contributor | 28089274
@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 Dec 13, 2023
@melvin-bot melvin-bot bot changed the title All - Settings - Red dot remains after error is cleared [$500] All - Settings - Red dot remains after error is cleared Dec 13, 2023
Copy link

melvin-bot bot commented Dec 13, 2023

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

Copy link

melvin-bot bot commented Dec 13, 2023

Job added to Upwork: https://www.upwork.com/jobs/~012ec660a67cb6d223

Copy link

melvin-bot bot commented Dec 13, 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 melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 13, 2023
Copy link

melvin-bot bot commented Dec 13, 2023

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

@AmjedNazzal
Copy link
Contributor

Proposal

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

All - Settings - Red dot remains after error is cleared

What is the root cause of that problem?

In deleteContactMethod, we are clearing errorFields.deletedLogin but we aren't clearing errorFields.addedLogin which is a part of the failureData of addNewContactMethodAndNavigate.

When we delete a contact method, we expect a green dot to show up while the deletion is being processed, this is added intentionally by using pendingFields.deletedLogin: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE as shown below in the code, however this green dot is override by red dot because of errorFields.addedLogin

function deleteContactMethod(contactMethod, loginList) {
const oldLoginData = loginList[contactMethod];
const optimisticData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.LOGIN_LIST,
value: {
[contactMethod]: {
partnerUserID: '',
errorFields: {
deletedLogin: null,
},
pendingFields: {
deletedLogin: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,

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

We should clear that errorField on contact method deletion so the red dot doesn't show up during the deletion process

function deleteContactMethod(contactMethod, loginList) {
    ....
    value: {
        [contactMethod]: {
            ....
            errorFields: {
                deletedLogin: null,
                addedLogin: null,
            },

Result

Screen.Recording.2023-12-14.at.2.31.09.AM.mov

@sfurqan2
Copy link

Proposal

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

Red dot remains after error is cleared when network connection is simulating slow network requests

What is the root cause of that problem?

The root cause of the problem is that in Contact Page there is an additional check which hides new contact requests with pendingAction "delete".

const hideChildren = shouldHideOnDelete && !isOffline && pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && !hasErrors;

However, this check is missing from userUtils "hasLoginListError" function.

function hasLoginListError(loginList: Record<string, Login>): boolean {
    return Object.values(loginList).some((loginData) => Object.values(loginData.errorFields ?? {}).some((field) => Object.keys(field ?? {}).length > 0));
}

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

Logic on both ends should be kept consistent so I would suggest we implement the same checks in userUtils and call it. This will maintain the DRY principle as well as is easier to maintain.

What alternative solutions did you explore? (Optional)

N/A

Copy link

melvin-bot bot commented Dec 14, 2023

📣 @sfurqan2! 📣
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>

@sfurqan2
Copy link

Contributor details
Your Expensify account email: sfurqan1999@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~0163c31a5a31c72f3f

Copy link

melvin-bot bot commented Dec 14, 2023

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

@tienifr
Copy link
Contributor

tienifr commented Dec 14, 2023

Proposal

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

The red dot remains on user avatar on the home screen and in settings

What is the root cause of that problem?

When adding login and have failure, the addedLogin error field will have value here. When we delete the contact method, it should have cleared all Onyx data here after successful API request, but because we're still turning on the "Simulate failing network requests", the delete contact method request remains pending for a while, so the red dot shows because the addedLogin error field is still there.

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

As we can see, we're making a redundant and unnecessary API call here, since the contact method fails to be added, there's no point in calling 'DeleteContactMethod' when deleting it. We should only call 'DeleteContactMethod' if the contact method was added successfully and it's stored in the back-end.

This also leads to the login data still being available while the API call is being made, causing this issue.

We should treat this as any other case where we clear the error, we should clear the Onyx data only because the action fails and there's nothing to so in back-end side. In here, when removing contact method that failed to be added, clearing in Onyx is enough.

if (oldLoginData.errorFields.addedLogin) {
    Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.route);
    // If the contact method failed to be added, we can just remove it from Onyx
    Onyx.merge(ONYXKEYS.LOGIN_LIST, {
        [contactMethod]: null,
    });
    return;
}

What alternative solutions did you explore? (Optional)

We can clear the errorFields optimistically when trying to delete contact method, then potentially restore it if the contact method deletion fails, this will make sure the contact method with proper error is shown again if the contact deletion itself fails, as mentioned here.

In here

errorFields: null,

In here

errorFields: {
    ...oldLoginData.errorFields,
    deletedLogin: null,
},

Or we can remove and restore only the addedLogin error if we want to.

@bernhardoj
Copy link
Contributor

Immediately clear the onyx when add fails is intentionally removed here

@tienifr
Copy link
Contributor

tienifr commented Dec 14, 2023

@bernhardoj thanks for the link! But I think it was removed because we assumed that it won't cause any issue, but it clearly does cause issue here and it wouldn't hurt us if reintroducing it.

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

melvin-bot bot commented Dec 19, 2023

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

@ntdiary
Copy link
Contributor

ntdiary commented Dec 19, 2023

under review.

@melvin-bot melvin-bot bot removed the Overdue label Dec 19, 2023
@ntdiary
Copy link
Contributor

ntdiary commented Dec 20, 2023

Immediately clear the onyx when add fails is intentionally removed here

Based on the goal of this PR, I don't think we should revert the local condition.
Additionally, this issue may not be a bug.
After we click the Remove button, because we have enabled Simulate failing network requests, the DeleteContactMethod api should also fail, the removed contact method will also reappear later, I think it is expected behavior. However, it seems that we did not wait for it to complete. 😂

test.mp4

Because our app defaults to retrying requests 10 times, we can see from the video that it takes a long time for the results of add and delete to be displayed. By the way, if we want to improve that delay, we should think from a more general perspective, not just for this case. 🙂

Copy link

melvin-bot bot commented Dec 20, 2023

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

@AmjedNazzal
Copy link
Contributor

@ntdiary Any feedback on my proposal?

@melvin-bot melvin-bot bot added the Overdue label Dec 22, 2023
@ntdiary
Copy link
Contributor

ntdiary commented Dec 22, 2023

I think we need to clarify the expected result in the OP first.
Actually, because we have already enabled Simulate failing network requests, so clear the error would also fail (automatically retried 10 times), as shown in my previous video, the cleared contact method was displayed again. In this situation, having the red dot displayed is expected result.

cc @lanitochka17, @michaelhaxhiu

@melvin-bot melvin-bot bot removed the Overdue label Dec 22, 2023
@kbecciv kbecciv changed the title [$500] All - Settings - Red dot remains after error is cleared [$500] Settings - Red dot remains after error is cleared Dec 22, 2023
@melvin-bot melvin-bot bot added the Weekly KSv2 label Jan 9, 2024
Copy link

melvin-bot bot commented Jan 18, 2024

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@danieldoglas
Copy link
Contributor

@tienifr @ntdiary can you please take a look into #34758 and check if it's related ? cc @dangrous

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jan 19, 2024
@melvin-bot melvin-bot bot changed the title [$500] Settings - Red dot remains after error is cleared [HOLD for payment 2024-01-26] [$500] Settings - Red dot remains after error is cleared Jan 19, 2024
Copy link

melvin-bot bot commented Jan 19, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 19, 2024
Copy link

melvin-bot bot commented Jan 19, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.27-1 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-01-26. 🎊

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

Copy link

melvin-bot bot commented Jan 19, 2024

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:

  • [@ntdiary] The PR that introduced the bug has been identified. Link to the PR:
  • [@ntdiary] 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:
  • [@ntdiary] 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:
  • [@ntdiary] Determine if we should create a regression test for this bug.
  • [@ntdiary] 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.
  • [@michaelhaxhiu] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@ntdiary
Copy link
Contributor

ntdiary commented Jan 19, 2024

@tienifr @ntdiary can you please take a look into #34758 and check if it's related ? cc @dangrous

@danieldoglas. Has provide an explanation in Issue #34758 (comment). :)

@melvin-bot melvin-bot bot added the Overdue label Jan 29, 2024
@dangrous
Copy link
Contributor

Hi! I just wanted to call it out here - I'm closing out #34758 as not a bug, but I'm pretty sure it means that QA was never able to successfully QA this issue. It would be great if y'all could make sure this works as expected on this issue!

@danieldoglas
Copy link
Contributor

@ntdiary let's do the bugzero checklist here

@melvin-bot melvin-bot bot removed the Overdue label Jan 31, 2024
@michaelhaxhiu
Copy link
Contributor

Next step is with @ntdiary to do the regression steps

@ntdiary
Copy link
Contributor

ntdiary commented Feb 1, 2024

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:

I think this is a small edge case we overlooked during the development of the contact details page, so it's okay to just leave a comment in the original PR, no regression test is needed. :)

@danieldoglas danieldoglas added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Feb 1, 2024
Copy link

melvin-bot bot commented Feb 1, 2024

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Feb 1, 2024
@danieldoglas
Copy link
Contributor

cc @miljakljajic can you please proceed with the payment on this issue? Thanks!

@miljakljajic
Copy link
Contributor

Paid and paid!

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

10 participants