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 2025-01-22] [$250] Status message not cleared after the specified "Clear after" date #53518

Closed
1 of 8 tasks
m-natarajan opened this issue Dec 4, 2024 · 34 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 External Added to denote the issue can be worked on by a contributor

Comments

@m-natarajan
Copy link

m-natarajan commented Dec 4, 2024

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: 9.0.71-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
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: @rafecolton
Slack conversation (hyperlinked to channel name): ts_external_expensify_bugs

Action Performed:

  1. Set a status message with a "Clear after" date in the profile.
  2. Wait until the specified "Clear after" date has passed.
  3. Check if the status message is automatically cleared.

Expected Result:

The status message should be automatically cleared once the "Clear after" date is reached, ensuring timely updates to the display.

Actual Result:

The status message remains visible even after the "Clear after" date.

Workaround:

Unknown

Platforms:

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

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Recording.816.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021864198631680121664
  • Upwork Job ID: 1864198631680121664
  • Last Price Increase: 2024-12-04
Issue OwnerCurrent Issue Owner: @MitchExpensify
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 4, 2024
Copy link

melvin-bot bot commented Dec 4, 2024

Triggered auto assignment to @MitchExpensify (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.

@Shahidullah-Muffakir
Copy link
Contributor

Shahidullah-Muffakir commented Dec 4, 2024

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

Custom status is not cleared automatically, if the time defined is reached

What is the root cause of that problem?

It is not considered anywhere, it only clears if users manually clear it by clicking on the clearing status button.

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

in the ProfilePage, add this useEffect:

function ProfilePage() {

 useEffect(() => {
        if (currentUserPersonalDetails?.status && currentUserPersonalDetails.status.clearAfter) {
            const clearAfterDate = new Date(currentUserPersonalDetails.status.clearAfter);
            const currentDate = new Date();
            // Check if the status has expired
            if (clearAfterDate <= currentDate) {
                // Clear the status
                User.clearCustomStatus();
            }
        }
    }, [currentUserPersonalDetails?.status]);

and we may use this as well:

User.updateDraftCustomStatus({
         text: '',
         emojiCode: '',
         clearAfter: DateUtils.getEndOfToday(),
     });

@saifelance
Copy link

Proposal

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

The status message with a "Clear after" date doesn't automatically clear after the specified date, leaving outdated information on the profile.

What is the root cause of that problem?

The component lacks logic to check and clear the status message after the "Clear after" date has passed.

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

Solution:

  1. Implement a check to compare the current date with the "Clear after" date.
  2. If passed, clear the status message.
  3. Use useEffect to update the status when currentUserPersonalDetails is updated.

App/src/pages/settings/Profile/ProfilePage.tsx

useEffect(() => {
    const clearDate = currentUserPersonalDetails?.status?.clearAfterDate;
    if (clearDate && new Date(clearDate) <= new Date()) {
        // Clear the status message
        const updatedStatus = { ...currentUserPersonalDetails?.status, text: '', emojiCode: '' };
        setStatus(updatedStatus); // Assuming setStatus is a function to update the state
    }
}, [currentUserPersonalDetails]);

What alternative solutions did you explore? (Optional)

  1. Use a background job or cron job for server-side clearing (more complex).
  2. Create an API endpoint to clear the status (scalable but adds complexity).

@rafecolton rafecolton added the External Added to denote the issue can be worked on by a contributor label Dec 4, 2024
@melvin-bot melvin-bot bot changed the title Status message not cleared after the specified "Clear after" date [$250] Status message not cleared after the specified "Clear after" date Dec 4, 2024
Copy link

melvin-bot bot commented Dec 4, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 4, 2024
Copy link

melvin-bot bot commented Dec 4, 2024

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

@nkdengineer
Copy link
Contributor

Proposal

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

The status message remains visible even after the "Clear after" date.

What is the root cause of that problem?

We don't have any logic to clear the status when the clearAfter time is outdated

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

We should add a useEffect in AuthScreen to clear the status when the clearAfter time is outdated. If the current time is more than clearAfter, clear the status immediately. If the current time is less than the clearAfter, create a setTimeout to clear the status after the time is archived

const clearStatus = () => {
    User.clearCustomStatus();
    User.updateDraftCustomStatus({
        text: '',
        emojiCode: '',
        clearAfter: DateUtils.getEndOfToday(),
    });
};
useEffect(() => {
    const currentTime = format(new Date(), 'yyyy-MM-dd HH:mm:ss');
    if (!currentUserPersonalDetails.status?.clearAfter) {
        return;
    }
    if (currentUserPersonalDetails.status?.clearAfter > currentTime) {
        const subMilisecondsTime = new Date(currentUserPersonalDetails.status?.clearAfter).getTime() - new Date(currentTime).getTime();
        const timeoutID = setTimeout(() => {
            clearStatus();
        }, subMilisecondsTime);
        return () => {
            clearTimeout(timeoutID);
        };
    }

    clearStatus();
}, [currentUserPersonalDetails.status?.clearAfter]);

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

I don't think we need to add a unit test in this case because the new logic is an useEffect in the component

What alternative solutions did you explore? (Optional)

@shubham1206agra
Copy link
Contributor

This should be fixed via BE Pusher updates.

@MitchExpensify
Copy link
Contributor

So you think this is an internal issue @shubham1206agra ?

@eh2077
Copy link
Contributor

eh2077 commented Dec 5, 2024

This should be fixed via BE Pusher updates.

While I think frontend improvement is also necessary for offline use cases.

@shubham1206agra
Copy link
Contributor

So you think this is an internal issue @shubham1206agra ?

@MitchExpensify Yes

@shubham1206agra
Copy link
Contributor

This should be fixed via BE Pusher updates.

While I think frontend improvement is also necessary for offline use cases.

If you have a solution without setTimeout, feel free to propose it.

@eh2077
Copy link
Contributor

eh2077 commented Dec 5, 2024

@shubham1206agra Interesting! Would you mind sharing your concern about using setTimeout? I searched the codebase and found there's a similar use case in MapboxToken.ts

Cc @nkdengineer

@shubham1206agra
Copy link
Contributor

@eh2077 This problem can be solved without setTimeout. So I think we should prefer that.

@eh2077
Copy link
Contributor

eh2077 commented Dec 5, 2024

@eh2077 This problem can be solved without setTimeout. So I think we should prefer that.

@shubham1206agra Do you mean the BE pusher solution? But that won't help for offline use case right?

@rafecolton
Copy link
Member

I think we need both actually. The proposed solution is good for offline or if you happen to be online when your status expires. If your status expires and you're not online right away, we still need it to update for anyone who has a conversation with you, so that will require a BE change.

There's a potential edge case I think that goes like this:

  1. Set an expiring status on one client (e.g. phone)
  2. After that status expires, log in on another client (e.g. desktop). It is cleared.
  3. Set a non-expiring status on the second client (desktop).
  4. Open the app on the first device (phone) while offline. It will clear your status. Then reconnect - I expect, though I haven't tested, that it would clear the status you set in (3).

So think the actual solution is:

  1. On the client, check if the status is expired. If it is, clear it from being displayed but do not press the clear button (i.e. don't send the request to the server)
  2. Also clear the status server-side using pusher
  3. When the client re-connects, it should get the update that includes that the status was cleared
  4. If the status was set on another device, the client gets that new status when it reconnects
  5. If status was set in two different places, use whichever happened later. e.g.:
    1. I set an expiring status on my phone, then take my phone offline
    2. Status expires
    3. I load the app on desktop and set a new status
    4. I open my phone, still online. Local status is cleared automatically, and I manually set another one.
    5. Then I take my phone online - I expect the status I set on desktop will be replaced by the one I set on my phone, since it happened later.

@eh2077
Copy link
Contributor

eh2077 commented Dec 6, 2024

@rafecolton Excellent summary! For the edge case about managing updates from different devices (online and offline), there's an old similar issue #41911 and slack discussion

Open the app on the first device (phone) while offline. It will clear your status. Then reconnect - I expect, though I haven't tested, that it would clear the status you set in (3).

If the App calls the CLEAR_STATUS command, then yes the status set in (3) will be cleared. I agree with you that it'll be better to just hide the expired status and not to call the clear command.

iv. I open my phone, still online offline. Local status is cleared automatically, and I manually set another one.
v. Then I take my phone online - I expect the status I set on desktop will be replaced by the one I set on my phone, since it happened later.

So, this should be expected according to slack comment


For frontend fix, I think we can go with @nkdengineer 's proposal. Just need to note

On the client, check if the status is expired. If it is, clear it from being displayed but do not press the clear button (i.e. don't send the request to the server)

as suggested by @rafecolton

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Dec 6, 2024

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

@shubham1206agra
Copy link
Contributor

Sorry @eh2077

But I will give my 2 cents here

We should just do conditional check on clearAfter date on FE, and this will help other people status which have clearAfter time.

@melvin-bot melvin-bot bot added Overdue and removed Help Wanted Apply this label when an issue is open to proposals by contributors labels Dec 9, 2024
Copy link

melvin-bot bot commented Dec 9, 2024

❌ There was an error making the offer to @nkdengineer for the Contributor role. The BZ member will need to manually hire the contributor.

Copy link

melvin-bot bot commented Jan 3, 2025

This issue has not been updated in over 15 days. @rlinoz, @MitchExpensify, @eh2077, @nkdengineer eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@rlinoz
Copy link
Contributor

rlinoz commented Jan 3, 2025

PR is being reviewed, I am still trying to understand why the job is not always clearing the status though

@rlinoz rlinoz added Weekly KSv2 and removed Monthly KSv2 labels Jan 3, 2025
@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 15, 2025
@melvin-bot melvin-bot bot changed the title [$250] Status message not cleared after the specified "Clear after" date [HOLD for payment 2025-01-22] [$250] Status message not cleared after the specified "Clear after" date Jan 15, 2025
Copy link

melvin-bot bot commented Jan 15, 2025

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 15, 2025
Copy link

melvin-bot bot commented Jan 15, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.85-4 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 2025-01-22. 🎊

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

  • @eh2077 requires payment through NewDot Manual Requests
  • @nkdengineer requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented Jan 15, 2025

@eh2077 @MitchExpensify @eh2077 The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@MitchExpensify
Copy link
Contributor

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other:

Where bug was reported:

  • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
  • 2b. Reported on staging (eg. found during regression or PR testing)
  • 2d. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [Contributor] 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:

  • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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:

  • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

Regression Test Proposal Template
  • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

    Link to issue:

Regression Test Proposal

Precondition:

Test:

Do we agree 👍 or 👎

@MitchExpensify
Copy link
Contributor

Payment summary:

  • $250 @eh2077 requires payment through NewDot Manual Requests
  • $250 @nkdengineer requires payment (Needs manual offer from BZ)

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jan 22, 2025
Copy link

melvin-bot bot commented Jan 22, 2025

Payment Summary

Upwork Job

BugZero Checklist (@MitchExpensify)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1864198631680121664/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@melvin-bot melvin-bot bot added the Overdue label Jan 24, 2025
@MitchExpensify
Copy link
Contributor

@nkdengineer https://www.upwork.com/nx/wm/offer/105842031 Offer here for payment

@melvin-bot melvin-bot bot removed the Overdue label Jan 24, 2025
@MitchExpensify
Copy link
Contributor

@eh2077 can you please complete BZ steps? Thanks

@melvin-bot melvin-bot bot added the Overdue label Jan 27, 2025
@MitchExpensify
Copy link
Contributor

@eh2077 - bump

@melvin-bot melvin-bot bot removed the Overdue label Jan 27, 2025
@eh2077
Copy link
Contributor

eh2077 commented Jan 28, 2025

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other:

Where bug was reported:

  • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
  • 2b. Reported on staging (eg. found during regression or PR testing)
  • 2d. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [Contributor] 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: NA. This is a missing case of the status feature, so there's no recent PR that introduces the issue.

  • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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: NA

  • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

  • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

    Link to issue: https://github.com/Expensify/Expensify/issues/466657

Regression Test Proposal

Precondition:

NA

Test:

  1. Set a status message with a "Clear after" date in the profile.
  2. Wait until the specified "Clear after" date has passed.
  3. Check if the status message is automatically cleared.
  4. Verify that: The status message should be automatically cleared once the "Clear after" date is reached, ensuring timely updates to the display.

Do we agree 👍 or 👎

@JmillsExpensify
Copy link

$250 approved for @eh2077 based on confirmed payment summary.

@melvin-bot melvin-bot bot added the Overdue label Jan 30, 2025
Copy link

melvin-bot bot commented Jan 31, 2025

@rlinoz, @MitchExpensify, @eh2077, @nkdengineer Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

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 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

10 participants