Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.12k stars 2.62k forks source link

[HOLD for payment 2023-12-07] [$500] IOU - Cannot proceed to next month and dates appear blank when last day of month is selected #31793

Closed kbecciv closed 7 months ago

kbecciv commented 7 months ago

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.3.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:

Action Performed:

  1. Navigate to staging.new.expensify.com.
  2. Click FAB > Request money > Manual.
  3. Enter amount, choose participant and proceed to confirmation page.
  4. Click Show more > Date.
  5. Choose the date 31st Oct.
  6. Go to November.
  7. Choose the date 30th Sept.
  8. Go to October.

Expected Result:

In Step 6, user should be able to go to November. In Step 8, no blank dates will be shown.

Actual Result:

In Step 6, user is unable to go to November. In Step 8, blank dates are shown.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/Expensify/App/assets/93399543/51509968-5a3d-4b65-a4b4-7ba2d4ca964f

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01cc0d157099a8bbaa
  • Upwork Job ID: 1727778969100070912
  • Last Price Increase: 2023-11-23
  • Automatic offers:
    • s77rt | Reviewer | 27845856
    • paultsimura | Contributor | 27845858
melvin-bot[bot] commented 7 months ago

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

melvin-bot[bot] commented 7 months ago

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

melvin-bot[bot] commented 7 months ago

Bug0 Triage Checklist (Main S/O)

melvin-bot[bot] commented 7 months ago

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

paultsimura commented 7 months ago

Proposal

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

What is the root cause of that problem?

The issue is that in the CalendarPicker, we check if there are available dates next month by the following logic:

https://github.com/Expensify/App/blob/d521dd6783c382297e06a429701ae1936f808041/src/components/NewDatePicker/CalendarPicker/index.js#L130-L131

Here, if the next month has <= days than the selected day number, we compare the start of the day with the end of the same day (end of next month):

https://github.com/Expensify/App/blob/d521dd6783c382297e06a429701ae1936f808041/src/components/NewDatePicker/CalendarPicker/index.js#L187

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

We should simplify this logic to avoid unnecessary chained calculations and only check if the max allowed date is after the end of the current month. This would mean that there are available dates next month – at least the props.maxDate will be available. We should also modify the navigation to the previous month in a similar way.

const hasAvailableDatesNextMonth = startOfDay(new Date(this.props.maxDate)) > endOfMonth(new Date(this.state.currentDateView));
const hasAvailableDatesPrevMonth = endOfDay(new Date(this.props.minDate)) < startOfMonth(new Date(this.state.currentDateView));

Also, we'll need to prevent the non-existing days from being falsely marked as "selected" when navigating, so we should also add a !!day (or even !isDisabled) check here:

const isSelected = !!day && isSameDay(parseISO(this.props.value), new Date(currentYearView, currentMonthView, day));

https://github.com/Expensify/App/blob/d521dd6783c382297e06a429701ae1936f808041/src/components/NewDatePicker/CalendarPicker/index.js#L218-L222

Result:

https://github.com/Expensify/App/assets/12595293/50ca2707-a004-4ac5-9af2-a917f211d0db

What alternative solutions did you explore? (Optional)

rakshitjain13 commented 7 months ago

Proposal

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

Cannot proceed to next month and dates appear blank when the last day of the month is selected

What is the root cause of that problem?

Here will check for next month button should show or not, we are checking with the start time of the max date (last date of the current month) which cause the problem https://github.com/Expensify/App/blob/7a68a3d1003130e63065bcbef253c912a3431c08/src/components/NewDatePicker/CalendarPicker/index.js#L130

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

Here we should use the end of the day time instead of start time of max date

const hasAvailableDatesNextMonth = endOfDay(endOfMonth(new Date(this.props.maxDate))) > addMonths(new Date(this.state.currentDateView), 1);

What alternative solutions did you explore? (Optional)

NA

s77rt commented 7 months ago

@paultsimura Thanks for the proposal. Your RCA is correct and the solution looks good to me 👍.

PS: When raising a PR please add test case in CalendarPickerTest.js to prevent this from happening again.

🎀 👀 🎀 C+ reviewed Link to proposal

melvin-bot[bot] commented 7 months ago

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

s77rt commented 7 months ago

@rakshitjain13 Thanks for the proposal. Your RCA is correct. The suggested solution would work but it's not complete i.e. it does not fix the wrongly selected days

Screenshot 2023-11-24 at 5 27 57 PM
MonilBhavsar commented 7 months ago

Looks good. Agree we should simplify the logic

melvin-bot[bot] commented 7 months ago

📣 @s77rt 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job

melvin-bot[bot] commented 7 months ago

📣 @paultsimura 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻 Keep in mind: Code of Conduct | Contributing 📖

paultsimura commented 7 months ago

Thank you. The PR is ready for review: https://github.com/Expensify/App/pull/32073

melvin-bot[bot] commented 7 months ago

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

melvin-bot[bot] commented 7 months ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 1.4.5-7 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-12-07. :confetti_ball:

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

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

melvin-bot[bot] commented 7 months ago

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:

s77rt commented 7 months ago
miljakljajic commented 7 months ago

Both contracts paid and ended - thank you for your work!