-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Filter time expenses from workspaces with disabled time tracking #84655
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
Changes from all commits
4b4fc5b
af4ea06
7419245
5cbf8e3
ee67899
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ import {isPaidGroupPolicy} from '@libs/PolicyUtils'; | |
| import {findSelfDMReportID, generateReportID, isInvoiceRoomWithID} from '@libs/ReportUtils'; | ||
| import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils'; | ||
| import {endSpan} from '@libs/telemetry/activeSpans'; | ||
| import {getRequestType, hasRoute, isCorporateCardTransaction, isDistanceRequest, isPerDiemRequest} from '@libs/TransactionUtils'; | ||
| import {getRequestType, hasRoute, isCorporateCardTransaction, isDistanceRequest, isPerDiemRequest, isTimeRequest as isTimeRequestUtil} from '@libs/TransactionUtils'; | ||
| import MoneyRequestParticipantsSelector from '@pages/iou/request/MoneyRequestParticipantsSelector'; | ||
| import { | ||
| navigateToStartStepIfScanFileCannotBeRead, | ||
|
|
@@ -126,6 +126,7 @@ function IOURequestStepParticipants({ | |
| const isAndroidNative = getPlatform() === CONST.PLATFORM.ANDROID; | ||
| const isMobileSafari = isMobileSafariBrowser(); | ||
| const isPerDiem = isPerDiemRequest(initialTransaction); | ||
| const isTime = isTimeRequestUtil(initialTransaction); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new Useful? React with 👍 / 👎.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MelvinBot please check this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked into this. The concern about a hydration race window is not a new issue introduced by this PR — it's a pre-existing architectural characteristic that applies equally to all transaction-derived flags. Key findings:
If the hydration window were a real concern, it would need to be addressed as a separate issue for |
||
| const isCorporateCard = isCorporateCardTransaction(initialTransaction); | ||
|
|
||
| useEffect(() => { | ||
|
|
@@ -459,6 +460,7 @@ function IOURequestStepParticipants({ | |
| iouType={iouType} | ||
| action={action} | ||
| isPerDiemRequest={isPerDiem} | ||
| isTimeRequest={isTime} | ||
| isWorkspacesOnly={isWorkspacesOnly} | ||
| isCorporateCardTransaction={isCorporateCard} | ||
| /> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new filter only removes existing reports from the picker, but it does not guard the
Create reportpath, which still gets its destination fromusePolicyForMovingExpenses(that hook only validates per-diem constraints). In a time request flow where no valid report is selected yet (for example, moving an unreported/self-DM time expense), users can still create a new report in a workspace with time tracking disabled, so the restriction added here can be bypassed.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also seems pre-existing issue, @MelvinBot could you please confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is not a pre-existing issue — it's a genuine gap in the PR, unlike the previous hydration concern.
Key difference from per diem: The
usePolicyForMovingExpenseshook (src/hooks/usePolicyForMovingExpenses.ts:23-30) already guards the "Create report" path for per diem by checkingcanSubmitPerDiemExpenseFromWorkspace(policy). For time requests, no equivalent guard exists:The hook is called at
IOURequestStepReport.tsx:83with onlyisPerDiemRequest(transaction)— no time request flag is passed. So for a time expense, the "Create report" button could point to a workspace with time tracking disabled.To make this fully equivalent to per diem,
usePolicyForMovingExpenseswould need:isTimeRequestparameter(!isTimeRequest || isTimeTrackingEnabled(policy))check inisPolicyValidForMovingExpensesIOURequestStepReport.tsx:83would need to pass the time request flagThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MelvinBot fix that please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 5cbf8e3. Added
isTimeRequestparameter tousePolicyForMovingExpensesso the "Create report" path now filters out workspaces with time tracking disabled, mirroring the existing per diem guard.Changes:
usePolicyForMovingExpensesnow acceptsisTimeRequest?: booleanand checks(!isTimeRequest || isTimeTrackingEnabled(policy))inisPolicyValidForMovingExpensesand the active policy checkIOURequestStepReport,IOURequestEditReportCommon, andSearchTransactionsChangeReportto pass the new parameter