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

[Awaiting checklist completion] [$500] Request money - Calendar is showing the wrong date #31416

Closed
6 tasks done
lanitochka17 opened this issue Nov 16, 2023 · 52 comments
Closed
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Nov 16, 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.0-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. Go to staging.new.expensify.com
  2. Go to + > Request money > Manual
  3. Enter an amount and click Next
  4. Select a participant and proceed to the next page
  5. Click Show more
  6. Click Date

Expected Result:

The calendar is accurate

Actual Result:

The calendar is inaccurate. The dates are one day ahead. The week on the calendar starts from Monday to Sunday instead of Sunday to Saturday

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

Add any screenshot/video evidence

cal

Bug6278477_1700100895903.bandicam_2023-11-16_09-41-03-104.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0135c08e4c75c14697
  • Upwork Job ID: 1724983985857425408
  • Last Price Increase: 2023-11-16
  • Automatic offers:
    • 0xmiroslav | Reviewer | 27749707
    • barros001 | Contributor | 27749708
@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 Nov 16, 2023
@melvin-bot melvin-bot bot changed the title Request money - Calendar is showing the wrong date [$500] Request money - Calendar is showing the wrong date Nov 16, 2023
Copy link

melvin-bot bot commented Nov 16, 2023

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

Copy link

melvin-bot bot commented Nov 16, 2023

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

Copy link

melvin-bot bot commented Nov 16, 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 Nov 16, 2023
Copy link

melvin-bot bot commented Nov 16, 2023

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

@barros001
Copy link
Contributor

barros001 commented Nov 16, 2023

Proposal

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

Calendar / DatePicker weekdays header is off, ahead by one day.

What is the root cause of that problem?

App/src/libs/DateUtils.ts

Lines 148 to 151 in 5e01376

const startOfCurrentWeek = startOfWeek(new Date(), {weekStartsOn: 1}); // Assuming Monday is the start of the week
const endOfCurrentWeek = endOfWeek(new Date(), {weekStartsOn: 1}); // Assuming Monday is the start of the week

Code assumes week starts on Monday when rendering the weekdays header (I starts at 0)

// Add null values for days before the first day of the month
for (let i = 0; i < getDay(firstDayOfMonth); i++) {
currentWeek.push(null);
}

// Start a new row when the current week is full
if (getDay(currentDate) === 6) {
matrix.push(currentWeek);
currentWeek = [];
}
}

While the matrix of days assume it starts on Sunday (technically it checks it ends on Saturday by checking if day == 6 before starting a new week)

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

    const startOfCurrentWeek = startOfWeek(new Date(), {weekStartsOn: 0}); // Assuming Sunday is the start of the week
    const endOfCurrentWeek = endOfWeek(new Date(), {weekStartsOn: 0}); // Assuming Sunday is the start of the week

Update the start of the week to Sunday.

Before:
Screenshot 2023-11-15 at 10 11 29 PM

After:
Screenshot 2023-11-15 at 10 10 46 PM

Or update the matrix to use Monday as the start date:

    // Add null values for days before the first day of the month
    for (let i = 1; i < getDay(firstDayOfMonth); i++) { // changed starting value for I to 1
        currentWeek.push(null);
    }

        // Start a new row when the current week is full
        if (getDay(currentDate) === 0) { // changed to 0
            matrix.push(currentWeek);
            currentWeek = [];
        }

After:
Screenshot 2023-11-16 at 6 37 41 AM

This should align both elements of the calendar on when the week starts.

Another proposal below if we want to adapt to user's preferences, which might be better as people are used to different things depending on where they are.

What alternative solutions did you explore? (Optional)

The confusion here is because certain places in the world the week starts on Sunday while others on Monday. The matrix of days always assume Sunday as the start of the day and the header assumes Monday, that's why the disconnect. Another option would be to actually determine what's the first day of the week based on user's locale (preferredLocale: Locale) and adjust accordingly.

new Intl.Locale('en-us').weekInfo.firstDay could potentially be used, although might not be always available, which case we fallback to starting Sunday.

Something like this (code need polishing, just for illustration purposes):

    let weekStartsOn = 0; // Assuming Sunday is the default start of the week
    if (Intl && Intl.Locale) {
        const weekInfo = new Intl.Locale(preferredLocale).weekInfo;
        if (weekInfo && weekInfo.firstDay) {
            weekStartsOn = weekInfo.firstDay === 7 ? 0 : weekInfo.firstDay;
        }
    }

We could also hardcode the rules as the list of available Locales are hardcoded as well with only a few options. Basically en = Sunday, es = Monday.

We an extract this logic into a function on DateUtils.js and use it when generating the calendar header and date matrix. Once we determine the start of the week we could shift the days matrix accordingly.

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@tienifr
Copy link
Contributor

tienifr commented Nov 16, 2023

Proposal

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

The calendar is inaccurate. The dates are one day ahead. The week on the calendar starts from Monday to Sunday instead of Sunday to Saturday

What is the root cause of that problem?

In here, we're configuring for the week to start on Monday (1), but when generate the calendar day matrix, we still use utils getDay from date-fns in here which assumes the week starts on Sunday.

So for example, first day of November is a Wednesday, and getDay will return 3 (which is the index of Wed in week-start-at-Sunday-based date system, 0 - Sun, 1 - Mon, 2 - Tue, 3 - Wed), according to this we'll push 3 null values in the first week. Which is wrong since if the week starts on Mon, only Mon and Tue should be null.

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

Configure date-fns methods that are used to generate date matrix to assume the week starts on Monday.

For getDay inside here, we need to add a new method

const getDayWithWeekStartOnMonday = (date) => (getDay(date) + 6) % 7;

And use it in instead of getDay.

To explain more on that method, if the week starts on Monday, then:

  • Sunday will become index 6, aka (0 + 6) % 7 (0 is the result of getDay(date) based on week-start-on-Sunday calendar system, will be converted to 6 in the week-start-on-Monday-calendar system)
  • Monday will become index 0, aka (1 + 6) % 7
  • Tuesday will become index 1, aka (2 + 6) % 7
    ...

What alternative solutions did you explore? (Optional)

The number 6 above seems a bit random because we're assuming Monday. A more general implementation that will work for any weekStartsOn value is

const getDayWithWeekStartsOn = (date, weekStartsOn) => (getDay(date) - weekStartsOn + 7) % 7;

That might be more consistent with our implementation here, we can put 1 to a WEEK_STARTS_ON constant and reuse in both places for consistency.

If we're ok to let the week start on Sunday instead, we can remove the Monday customization here

@techdevelopers08
Copy link

techdevelopers08 commented Nov 16, 2023

I will review the date calculation logic in your code and will ensure that the dates are being calculated accurately. If the dates are consistently one day ahead, there might be an offset in your date calculations.
Verify that your application is handling time zones correctly. Inconsistencies in time zone handling can lead to date discrepancies. I I I will ensure that the server and client are configured to use the same time zone.
If you're using any third-party calendar libraries, make sure they are up to date
Steps:
step 1 -> we have to find calendarView in project
step 2 -> In calendarView we have to set US locale (US locale start from Sunday to Saturday ) because in android device Calendar depends on Locale and in your case may be locale working automatically according to location

Contributor details
Your Expensify account email: ajay@techangouts.com
Upwork Profile Link: https://www.upwork.com/freelancers/ajaychaudhary11

Copy link

melvin-bot bot commented Nov 16, 2023

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

Copy link

melvin-bot bot commented Nov 16, 2023

⚠️ Missing/invalid email or upwork profile link. Please make sure you add both your Expensify email and Upwork profile link in the format specified.

@barros001
Copy link
Contributor

Proposal

Updated

Added more details

@techdevelopers08
Copy link

I updated the details here

@melvin-bot melvin-bot bot added the Overdue label Nov 20, 2023
@twisterdotcom
Copy link
Contributor

@techdevelopers08 please complete the task here: #31416 (comment)

@0xmiroslav let us know if any of these proposals are good to go today please.

@melvin-bot melvin-bot bot removed the Overdue label Nov 20, 2023
@techdevelopers08
Copy link

@twisterdotcom I've updated my contribution details already here. Please update me if I missed anything.

@twisterdotcom
Copy link
Contributor

@techdevelopers08 you must post it as a single comment on its own for our automation to remember it.

@techdevelopers08
Copy link

Contributor details
Your Expensify account email: ajay@techangouts.com
Upwork Profile Link: https://www.upwork.com/freelancers/ajaychaudhary11

Copy link

melvin-bot bot commented Nov 20, 2023

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

@0xmiros
Copy link
Contributor

0xmiros commented Nov 20, 2023

I like @barros001's alternative solution to get the first day of the week from user locale and make it consistent throughout the app. We can fallback to either Sunday or Monday always if some user locale doesn't have that info for some reason.
🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Nov 20, 2023

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

@MonilBhavsar
Copy link
Contributor

Sounds good, let's fall back to Monday as default following the ISO convention -

The International Organization for Standardization (ISO) also follows this convention in its standard ISO 8601, where Monday is considered the first day of the week.

@0xmiros
Copy link
Contributor

0xmiros commented Dec 1, 2023

Ah I forgot that we already had conclusion. I will review PR during weekend. Please merge main

@barros001
Copy link
Contributor

barros001 commented Dec 1, 2023

main merged

@barros001
Copy link
Contributor

@0xmiroslav just checking again on this.

@barros001
Copy link
Contributor

@0xmiroslav do you think you can review the PR this week? This issue is pretty important IMO and we should try and get this pushed out quickly.

cc: @MonilBhavsar @twisterdotcom

@0xmiros
Copy link
Contributor

0xmiros commented Dec 19, 2023

sorry forgot this. will review today

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Dec 29, 2023
@melvin-bot melvin-bot bot changed the title [$500] Request money - Calendar is showing the wrong date [HOLD for payment 2024-01-05] [$500] Request money - Calendar is showing the wrong date Dec 29, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Dec 29, 2023
Copy link

melvin-bot bot commented Dec 29, 2023

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

Copy link

melvin-bot bot commented Dec 29, 2023

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

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.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

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

Copy link

melvin-bot bot commented Dec 29, 2023

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:

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

@twisterdotcom
Copy link
Contributor

twisterdotcom commented Jan 5, 2024

Payment Summary:

Awaiting checklist completion from @0xmiroslav now.

@twisterdotcom twisterdotcom removed the Awaiting Payment Auto-added when associated PR is deployed to production label Jan 5, 2024
@twisterdotcom twisterdotcom changed the title [HOLD for payment 2024-01-05] [$500] Request money - Calendar is showing the wrong date [Awaiting checklist completion] [$500] Request money - Calendar is showing the wrong date Jan 5, 2024
@0xmiros
Copy link
Contributor

0xmiros commented Jan 5, 2024

No need regression test because this was reported by QA team and we added automated tests to prevent this bug further.

@tienifr
Copy link
Contributor

tienifr commented Jan 6, 2024

Hi @twisterdotcom, according to the discussion here on this issue, I and @barros001 will be sharing compensation, and @barros001 also agreed with it by reacting here

Could you send me an Upwork job, thanks!

@tienifr
Copy link
Contributor

tienifr commented Jan 11, 2024

@twisterdotcom friendly bump on this, thanks!

@twisterdotcom twisterdotcom reopened this Jan 11, 2024
@twisterdotcom
Copy link
Contributor

Refund of $250 from @barros001 here.

Payment of $250 for @tienifr here.

@barros001
Copy link
Contributor

@twisterdotcom I was under the impression that @tienifr would get a separate payment instead of splitting the payment?

https://expensify.slack.com/archives/C01GTK53T8Q/p1700754871079609?thread_ts=1700483443.288289&cid=C01GTK53T8Q

Let @Carlos Barros implement this. Also give @Tienifr bonus for raising this discussion because without them, we could have implemented locale based solution

@tienifr
Copy link
Contributor

tienifr commented Jan 12, 2024

Payment of $250 for @tienifr here.

@twisterdotcom I accepted, thanks!

@twisterdotcom
Copy link
Contributor

Apologies @barros001 I am going off the comment you 👍 in Slack here about agreeing to split: https://expensify.slack.com/archives/C01GTK53T8Q/p1700757642008119?thread_ts=1700483443.288289&cid=C01GTK53T8Q
image

If it's a better middle ground, we can also not process the $250 refund and just pay out $250 for @tienifr.

@barros001
Copy link
Contributor

Apologies @barros001 I am going off the comment you 👍 in Slack here about agreeing to split: https://expensify.slack.com/archives/C01GTK53T8Q/p1700757642008119?thread_ts=1700483443.288289&cid=C01GTK53T8Q image

If it's a better middle ground, we can also not process the $250 refund and just pay out $250 for @tienifr.

@twisterdotcom yeah, the conversation was a little vague and not super clear. Ultimately we should do what’s right based on defined internal process (if any) for these cases. If it means I get to keep the full payment, great. If it means I should process the refund, that’s totally fine as well. Just let me know how to proceed and I’ll act accordingly.

@0xmiros
Copy link
Contributor

0xmiros commented Jan 12, 2024

@barros001 made good efforts for making complete PR so it seems not fair to me to split equal compensation between them. So I suggest to cancel refund (just my opinion. Final decision will be from internal team ofc)

@twisterdotcom
Copy link
Contributor

twisterdotcom commented Jan 15, 2024

Okay, I'm happy for you to reject the refund request @barros001. Sorry for the confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2
Projects
None yet
Development

No branches or pull requests

7 participants