You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2024-05-06] [$250] Can't update the custom time of the status to 00:59 #40495
Please re-state the problem that we are trying to solve in this issue.
The bug occurs not just for 00:59, it occurs for every time less than 1 hour. We cannot save the time
What is the root cause of that problem?
The bug occurs because the condition hour === 0 in the original code only checks if the hour part of the time is exactly 0. However, it doesn't consider the minutes part of the time. As a result, the condition hour === 0 allows times like 00:59 to pass through, even though they are less than one minute in the future.
What changes do you think we should make in order to solve the problem?
To fix this bug, we need to adjust the condition to also consider the minutes part of the time. By checking if both the hour is 0 and the minutes are less than or equal to 59, we ensure that times like 00:59 are properly detected as less than one minute in the future.
We need to add a && checks well to see if value is less than < 59 for minutes
constisTimeAtLeastOneMinuteInFuture=({ timeString, dateTimeString }: {timeString?: string;dateTimeString: string}): boolean=>{letdateToCheck=dateTimeString;if(timeString){const[hourStr,minuteStr]=timeString.split(/[:\s]+/);consthour=parseInt(hourStr,10);constminute=parseInt(minuteStr,10);// Check if time is 00:00if(hour===0&&minute===0){returnfalse;}dateToCheck=combineDateAndTime(timeString,dateTimeString);}constnow=newDate();returnisAfter(newDate(dateToCheck),addMinutes(now,1));};
What alternative solutions did you explore? (Optional)
The parsing issue, '00:59 AM' is not a standard representation of time. In a 12-hour clock system. Therefore, '00:59 AM' doesn't follow standard conventions because '00' usually represents midnight.
What changes do you think we should make in order to solve the problem?
We need to first remove the hour === 0 check and then we need to make some change to turn the time into standard representation of time in a 12-hour clock system.
}elseif(updatedTime.includes(':')){// it's in "hh:mm a" formatconst[time,ampm]=updatedTime.split(' ');const[hours,minutes]=time.split(':');lethour=parseInt(hours,10);if(ampm==='PM'&&hour!==12){hour+=12;}elseif(ampm==='AM'&&hour===12){hour=0;}consttempTime=parse(`${hour}:${minutes}`,'HH:mm',newDate());if(isValid(tempTime)){parsedTime=tempTime;}}
What alternative solutions did you explore? (Optional)
Below suggestions are from my original proposal, which have been moved to this section because design team mentioned that we only need to update the message.
Option 1:
We shouldn't be allowing the user to type 00.
As of now, when user types 14, it gets changed to 02 with PM. Same for other numbers > 12. Likewise, when user types 00, it should be changed to 12 AM.
changed the title [-][$250] Can't update the custom time of the status to 00:59[/-][+][HOLD for payment 2024-05-06] [$250] Can't update the custom time of the status to 00:59[/+]on Apr 29, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.67-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
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:
[@DylanDylann] The PR that introduced the bug has been identified. Link to the PR:
[@DylanDylann] 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:
[@DylanDylann] 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:
[@DylanDylann] Determine if we should create a regression test for this bug.
[@DylanDylann] 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.
[@garrettmknight] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
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:
[@DylanDylann] The PR that introduced the bug has been identified. Link to the PR: #24620
[@DylanDylann] 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: #24620 (comment)
[@DylanDylann] 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: NA
[@DylanDylann] Determine if we should create a regression test for this bug. Yes
[@DylanDylann] 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.
Regression Test Proposal
Create a new status
Set up a custom clear time for a status to 00:59
Verify that: error Please enter a time using the 12-hour clock format is displayed
Activity
melvin-bot commentedon Apr 18, 2024
Triggered auto assignment to @garrettmknight (
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.DylanDylann commentedon Apr 18, 2024
@garrettmknight I investigated this bug while discovering it. Could I take over this one as C+ role?
allgandalf commentedon Apr 18, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
The bug occurs not just for 00:59, it occurs for every time less than 1 hour. We cannot save the time
What is the root cause of that problem?
The bug occurs because the condition hour === 0 in the original code only checks if the hour part of the time is exactly 0. However, it doesn't consider the minutes part of the time. As a result, the condition hour === 0 allows times like 00:59 to pass through, even though they are less than one minute in the future.
We call validate below:
App/src/components/TimePicker/TimePicker.tsx
Lines 130 to 135 in 9033ccb
Which calls the below util:
App/src/libs/DateUtils.ts
Line 664 in 9033ccb
And we return false if hour is 0:
App/src/libs/DateUtils.ts
Lines 672 to 674 in 9033ccb
What changes do you think we should make in order to solve the problem?
To fix this bug, we need to adjust the condition to also consider the minutes part of the time. By checking if both the hour is 0 and the minutes are less than or equal to 59, we ensure that times like 00:59 are properly detected as less than one minute in the future.
We need to add a
&&checks well to see if value is less than< 59for minutesWhat alternative solutions did you explore? (Optional)
Krishna2323 commentedon Apr 18, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Can't update the custom time of the status to 00:59
What is the root cause of that problem?
There are two issue we need to handle here:
hour === 0check, this doesn' make a lot of sense here, I don't think we need that check.App/src/libs/DateUtils.ts
Lines 672 to 674 in 9033ccb
App/src/libs/DateUtils.ts
Lines 576 to 582 in 9033ccb
What changes do you think we should make in order to solve the problem?
We need to first remove the
hour === 0check and then we need to make some change to turn the time into standard representation of time in a 12-hour clock system.What alternative solutions did you explore? (Optional)
DylanDylann commentedon Apr 19, 2024
@Krishna2323
PLEASE PRIORITIZING YOUR PR BEFORE POSTING NEW PROPOSAL
nkdengineer commentedon Apr 19, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Error: Please choose a time at least one minute ahead
What is the root cause of that problem?
We have 2 problems:
0App/src/libs/DateUtils.ts
Lines 672 to 674 in 68e6962
parsefunction ofdate-fnslib returninvalid dateif the hour is 0 because the range of this format indate-fnsis1->12, they use 12 instead of 0What changes do you think we should make in order to solve the problem?
First we need to create new field in
en.tsxandes.tsxto introduce new errorIn TimePicker Component we should introduce new state called
errorMessageThen we need to update
validatefunctionApp/src/components/TimePicker/TimePicker.tsx
Line 130 in 64695c8
Finally, we update the message field here to use new state
errorMessageApp/src/components/TimePicker/TimePicker.tsx
Line 524 in 64695c8
Optional: We also should remove this condition because it is redundant
App/src/libs/DateUtils.ts
Lines 672 to 674 in 9033ccb
What alternative solutions did you explore? (Optional)
NA
ShridharGoel commentedon Apr 19, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Custom time of the status can't be set to any value with hour as 00.
What is the root cause of that problem?
We can add a new state errorMessage and update it via handleSubmit
Code can be polished.
Psuedo code for FormHelpMessage
Same change will be needed in
getTimeValidationErrorKeyin DateUtils.App/src/libs/DateUtils.ts
Lines 709 to 715 in 9a115b6
What alternate solutions did you explore?
Below suggestions are from my original proposal, which have been moved to this section because design team mentioned that we only need to update the message.
Option 1:
We shouldn't be allowing the user to type 00.
As of now, when user types 14, it gets changed to 02 with PM. Same for other numbers > 12. Likewise, when user types 00, it should be changed to 12 AM.
App/src/components/TimePicker/TimePicker.tsx
Lines 221 to 227 in 305f12c
In the above, add the below condition:
(Option 1 isn't good because when the user would delete the value for entering a new one, it will start showing 12 instead of 00)
Option 2:
When the user saves, we can change '00' in hours to '12', update to AM and then continue. Update the handleSubmit method in TimePicker.
Code can be polished.
Video for the above option 2
TimeChange.mov
ShridharGoel commentedon Apr 19, 2024
@shawnborton @dannymcclain Any thoughts on the flow shown in the video above?
shawnborton commentedon Apr 19, 2024
Given that we are clearly using AM/PM here, I would think we'd just throw an error saying that you can't enter "00" for the hour.
shawnborton commentedon Apr 19, 2024
So I think we just need a better error message.
melvin-bot commentedon Apr 19, 2024
Job added to Upwork: https://www.upwork.com/jobs/~0187eaa0221ed74ecf
44 remaining items
[-][$250] Can't update the custom time of the status to 00:59[/-][+][HOLD for payment 2024-05-06] [$250] Can't update the custom time of the status to 00:59[/+]melvin-bot commentedon Apr 29, 2024
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Apr 29, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.67-7 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-05-06. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Apr 29, 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:
garrettmknight commentedon May 9, 2024
All paid out - @DylanDylann can you complete the checklist when you get a chance?
DylanDylann commentedon May 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:
[@DylanDylann] The PR that introduced the bug has been identified. Link to the PR: #24620
[@DylanDylann] 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: #24620 (comment)
[@DylanDylann] 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: NA
[@DylanDylann] Determine if we should create a regression test for this bug. Yes
[@DylanDylann] 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.
Regression Test Proposal
Do we agree 👍 or 👎
garrettmknight commentedon May 10, 2024
All set