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-17] [$500] [WAVE 5][LOW] Settings - Year change by months does not change selection #33006

Closed
6 tasks done
izarutskaya opened this issue Dec 13, 2023 · 29 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 ECard Wave5-free-submitters External Added to denote the issue can be worked on by a contributor

Comments

@izarutskaya
Copy link

izarutskaya commented Dec 13, 2023

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: v1.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:
Slack conversation: @

Action Performed:

  1. Open the app
  2. Open settings->profile->personal details->date of birth
  3. Click on the year and select a year, observe that after value is changed, both background colour and green tick location are on the selected year
  4. Click year again > now click the forward arrow of the month (>) until you get to January
  5. Click on the year again and notice that the green checkmark is on the previously selected year and the highlight year is the new year

Expected Result:

App should change background color as well as green tick position for the selected or current calendar year

Actual Result:

App changes background color but does not change green tick position on change of year value by changing months value in calendar

Workaround:

Unknown

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

Bug6312056_1702491118045.windows_chrome_-_year_change_by_months_issue.mp4

image

image

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0102b1c7f6c3df6359
  • Upwork Job ID: 1735031332000718848
  • Last Price Increase: 2023-12-13
  • Automatic offers:
    • mollfpr | Reviewer | 28064580
    • ishpaul777 | Contributor | 28064581
@izarutskaya izarutskaya 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 Settings - Year change by months does not change selection [$500] Settings - Year change by months does not change selection Dec 13, 2023
Copy link

melvin-bot bot commented Dec 13, 2023

Triggered auto assignment to @Christinadobrzyn (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/~0102b1c7f6c3df6359

@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

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

Copy link

melvin-bot bot commented Dec 13, 2023

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

@ishpaul777
Copy link
Contributor

ishpaul777 commented Dec 13, 2023

Proposal

Problem

Year change by months does not change selection

Root Cause

When we add a month (here) to selected date or move to previous (here) we only modify the currentDateView state and isSelected field in years state is not changed when year is also changes

Changes

we need to change selected year in years state when year is added(move to next month) or subtracted(moveToprevMonth)

    /**
     * Handles the user pressing the previous month arrow of the calendar picker.
     */
    moveToPrevMonth() {
        this.setState((prev) => {
            const prevMonth = subMonths(new Date(prev.currentDateView), 1);
            // if year is subtracted, we need to update the years list
            let newYears = prev.years;
            if (prevMonth.getFullYear() < prev.currentDateView.getFullYear()) {
                newYears = _.map(prev.years, (item) => ({
                    ...item,
                    isSelected: item.value === prevMonth.getFullYear(),
                }));
            }

            return {
                ...prev,
                currentDateView: prevMonth,
                years: newYears,
            };
        });
    }

    /**
     * Handles the user pressing the next month arrow of the calendar picker.
     */
    moveToNextMonth() {
        this.setState((prev) => {
            const nextMonth = addMonths(new Date(prev.currentDateView), 1);
            // if year is added, we need to update the years list
            let newYears = prev.years;
            if (nextMonth.getFullYear() > prev.currentDateView.getFullYear()) {
                newYears = _.map(prev.years, (item) => ({
                    ...item,
                    isSelected: item.value === nextMonth.getFullYear(),
                }));
            }

            return {
                ...prev,
                currentDateView: nextMonth,
                years: newYears,
            };
        });
    }

@ZhenjaHorbach
Copy link
Contributor

ZhenjaHorbach commented Dec 13, 2023

Proposal

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

Settings - Year change by months does not change selection

What is the root cause of that problem?

The main problem is that the selected year changes thanks only to onYearSelected which call only when we set year

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

Instead of duplicating the logic for changing the selected year, we can simply add a listener

We can add new useEffect which will listen currentYear for YearPickerModal when our modal is not visible

function YearPickerModal(props) {

    useEffect(() => {
        if (!props.isVisible) {
            props.onYearChange(props.currentYear);
        }
    }, [props.currentYear, props.isVisible]);

What alternative solutions did you explore? (Optional)

As alternative we can use componentDidUpdate inside CalendarPicker

class CalendarPicker extends React.PureComponent {

    componentDidUpdate(prevProps, prevState) {
        if (this.state.currentDateView.getFullYear() !== prevState.currentDateView.getFullYear()) {
            this.onYearSelected(this.state.currentDateView.getFullYear());
        }
    }

@Christinadobrzyn
Copy link
Contributor

I can reproduce this - I think it's a low priority but I think it could be part of [ECARD] LOW: Settings - Remove unnecessary requirement for dateOfBirth when creating physical cards in Marqeta#316704

Adding it to that Wave to evaluate this change!

@ishpaul777
Copy link
Contributor

ishpaul777 commented Dec 13, 2023

@Christinadobrzyn i think we should treat this as normal priorty issue because the Calendar component is widely used in app, in bank account flow, money request and date of birth, and it looks like visual inconsistency which feels broken, user may encounter this in a normal flow of using app

@tienifr
Copy link
Contributor

tienifr commented Dec 14, 2023

Proposal

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

Settings - Year change by months does not change selection

What is the root cause of that problem?

  1. In CalendarPicker we store years but did not use it in CalendarPicker, we just pass it to YearPickerModal. So it can make our component re-renders unexpectedly
  2. To show the selected year, we have to check isSelected here, but when year changes by months, we did not call onYearSelected so years sections is not updated

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

  1. We should not store years in CalendarPicker, because we did not use it in CalendarPicker. We should calculate years in YearPickerModal. We will pass minYear, maxYear instead of years
  2. When calculate years in YearPickerModal, we check isSelected=value === props.currentYear so we can make sure the currentYear will be selected
    const initialYears = useRef(_.map(
        Array.from({length: props.maxYear - props.minYear + 1}, (v, i) => i + props.minYear),
        (value) => ({
            text: value.toString(),
            value,
            keyForList: value.toString(),
        }),
    ))

    const years = useMemo(()=>{
        return _.map(
            initialYears.current,
            (year) => ({
                ...year,
                isSelected: year.value === props.currentYear,
            }),
        )
    },[props.currentYear])

Result

Screen.Recording.2023-12-14.at.11.30.35.mov

@dylanexpensify dylanexpensify added the ECard Wave5-free-submitters label Dec 14, 2023
@dylanexpensify dylanexpensify changed the title [$500] Settings - Year change by months does not change selection [$500] LOW: Settings - Year change by months does not change selection Dec 14, 2023
@Christinadobrzyn
Copy link
Contributor

Hi @ishpaul777 it looks like this job will be treated with our normal priority.

@mollfpr feel free to evaluate the provided proposal to see if any will work. Thanks!

@Christinadobrzyn Christinadobrzyn changed the title [$500] LOW: Settings - Year change by months does not change selection [$500] [WAVE 5][LOW] Settings - Year change by months does not change selection Dec 15, 2023
@flodnv
Copy link
Contributor

flodnv commented Dec 15, 2023

I think it could be part of https://github.com/Expensify/Expensify/issues/316704

FWIW this is unrelated

Copy link

melvin-bot bot commented Dec 18, 2023

@mollfpr, @Christinadobrzyn Whoops! This issue is 2 days overdue. Let's get this updated quick!

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

mollfpr commented Dec 18, 2023

I feel the proposal from @ishpaul777 is the correct way to handle this issue. It makes it easier to maintain the prev/next month's function.

🎀 👀 🎀 C+ reviewed!

Copy link

melvin-bot bot commented Dec 18, 2023

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

@Christinadobrzyn
Copy link
Contributor

still working on a review - @danieldoglas when you have a moment can you check on this decision - #33006 (comment)

@mollfpr
Copy link
Contributor

mollfpr commented Dec 20, 2023

@Christinadobrzyn, I think we already let @ishpaul777 work on the issue. We need to wait for the PR to be ready.

ishpaul777 added a commit to ishpaul777/App that referenced this issue Dec 20, 2023
@ishpaul777 ishpaul777 mentioned this issue Dec 20, 2023
50 tasks
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Dec 21, 2023
@Christinadobrzyn
Copy link
Contributor

hi @mollfpr just checking on the PR review!

@mollfpr
Copy link
Contributor

mollfpr commented Dec 22, 2023

@Christinadobrzyn Yup, working on it!

@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 10, 2024
@melvin-bot melvin-bot bot changed the title [$500] [WAVE 5][LOW] Settings - Year change by months does not change selection [HOLD for payment 2024-01-17] [$500] [WAVE 5][LOW] Settings - Year change by months does not change selection Jan 10, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 10, 2024
Copy link

melvin-bot bot commented Jan 10, 2024

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

Copy link

melvin-bot bot commented Jan 10, 2024

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

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

Copy link

melvin-bot bot commented Jan 10, 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:

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jan 16, 2024
@mollfpr mollfpr mentioned this issue Jan 18, 2024
57 tasks
@mollfpr
Copy link
Contributor

mollfpr commented Jan 18, 2024

[@mollfpr] The PR that introduced the bug has been identified. Link to the PR:

#21792

[@mollfpr] 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:

https://github.com/Expensify/App/pull/21792/files#r1457723732

[@mollfpr] 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:

The regression step should be enough.

[@mollfpr] Determine if we should create a regression test for this bug.
[@mollfpr] 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.

  1. Sign in to the App
  2. Navigate to settings -> profile -> DOB
  3. Click the forward arrow of the month (>) until you get to January. Note that the year has changed. Now open the year picker and verify the changed year is highlighted
  4. Click the backward arrow of the month (<) until you get to December; note the year has changed. Now open the year picker and verify the changed year is highlighted

@Christinadobrzyn Could you give the payment summary for the manual request in NewDot? Thank you!

@melvin-bot melvin-bot bot added the Overdue label Jan 22, 2024
@danieldoglas
Copy link
Contributor

Just awaiting payment, not overdue. cc @Christinadobrzyn

@melvin-bot melvin-bot bot removed the Overdue label Jan 22, 2024
@Christinadobrzyn
Copy link
Contributor

Sorry for the delay here

Regression test here- https://github.com/Expensify/Expensify/issues/363007

Payouts due:

Issue Reporter: NA
Contributor: $500 @ishpaul777 (Paid in Upwork)
Contributor+: $500 @mollfpr - you get paid in NewDot or Upwork?

Eligible for 50% #urgency bonus? NA

Upwork job is here. The upwork job is now closed so let me know if you need payment through Upwork and I'll create a new job

@mollfpr
Copy link
Contributor

mollfpr commented Jan 24, 2024

Thanks @Christinadobrzyn I'll request the payment in NewDot.

@JmillsExpensify
Copy link

$500 approved for @mollfpr based on summary above.

@Christinadobrzyn
Copy link
Contributor

awesome! I think we're good to close this. Thanks all!

@github-project-automation github-project-automation bot moved this from Release 5: Best in Class to Done in [#whatsnext] Wave 05 - Deprecate Free Jan 25, 2024
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 ECard Wave5-free-submitters External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Development

No branches or pull requests

10 participants