Repository navigation
[CFI] Flatten the Per Diem flow and use in-line fields - #105421
thelullabyy wants to merge 15 commits into
Conversation
|
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@ikevin127 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: Nativescreen-20261102-172924-1793669251136.mp4MacOS: Chrome / SafariScreen.Recording.2026-11-02.at.16.47.27.mov |
ikevin127
left a comment
There was a problem hiding this comment.
Dropped (8) code-comments below, two are 🟠: a back-navigation bug on the standalone per diem confirmation, and a shared TimeModalPicker change that restyles the Vacation Delegate form.
⚠️ Description findings
- "Explanation of Change" is empty
- "Tests" only link to the desig, there are no numbered steps and no failure cases
- melvin-bot already asked for
FORMS.mdto cover theValueFieldDropdownaddition toValidInputs
| ), | ||
| ); | ||
| // The standalone per diem confirmation is only reached from the workspace selector on the create page. | ||
| Navigation.goBack(ROUTES.MONEY_REQUEST_CREATE.getRoute(action, iouType, initialTransactionID, reportID, backToReport)); |
There was a problem hiding this comment.
🟠 This back path won't match the CREATE route underneath, so it replaces the confirmation instead of popping it.
The confirmation's reportID is the workspace expense chat that IOURequestStepPerDiemWorkspace navigated with, while the CREATE route below still carries the original global create reportID. goUp compares params by default, so it finds no match.
Before this PR it worked because the destination step in between carried the workspace reportID. Now nothing sits between the two routes.
Result: back from the confirmation lands on a second CREATE route pointed at the workspace chat, which shows the inline per diem form instead of the workspace selector. One more back gets you to the real start page.
The confirmation sits directly on top of the create page now, so a plain pop should do:
// The standalone per diem confirmation is only reached from the workspace selector on the create page.
Navigation.goBack();👁️ Written by AI, reviewed by Kevin.
There was a problem hiding this comment.
Good catch, thanks. Switched it to a plain Navigation.goBack(). The standalone per diem confirmation is only reached from the workspace selector, so it always sits right on top of the create page.
| <View ref={ref}> | ||
| <ExpenseFieldRow | ||
| name={label} | ||
| value={currentTime} | ||
| onPress={() => setIsPickerVisible(true)} | ||
| errorText={errorText} | ||
| /> | ||
| </View> |
There was a problem hiding this comment.
🟠 TimeModalPicker is shared, and VacationDelegateForm uses it for the "clear after" time, so this restyles that form too.
ExpenseFieldRow brings its own mh4 and mv2, but the date input above it in VacationDelegateForm sits inside ph5, and the time row is only wrapped in mt2. The time field ends up 4px wider than the date field on each side, with extra vertical spacing, on a page this PR doesn't touch.
ExpenseFieldRow also lives under MoneyRequestConfirmationList/sections, so a generic form input now depends on the expense form.
Could we keep TimeModalPicker as it was and swap the row only on the per diem time page? A prop to pick the row style, or a per diem specific wrapper, would work. Otherwise please update VacationDelegateForm and attach a screenshot of it.
👁️ Written by AI, reviewed by Kevin.
There was a problem hiding this comment.
Agreed. TimeModalPicker is back to its original MenuItemWithTopDescription row, so VacationDelegateForm is unchanged. The modal moved into a shared TimePickerModal, and the per diem time page now uses its own PerDiemTimeField, which draws the bordered ExpenseFieldRow. The generic input no longer depends on the expense form.
| if (targetIouType !== iouType) { | ||
| navigation.setParams({iouType: targetIouType}); | ||
| } |
There was a problem hiding this comment.
🟡 navigation.setParams({iouType: targetIouType}) rewrites iouType on the shared CREATE route, which the other tabs read too.
This effect runs as soon as the per diem tab mounts, before the user picks anything. From global create (iouType = create) with a single per diem workspace, just landing on the tab switches the route to the target type (e.g. submit).
If the user then goes back to Manual or Scan, those tabs start with that iouType instead of create, which can limit the participants they offer.
The old flow put targetIouType only on the routes it pushed and left the start route alone. Can we keep targetIouType in the draft or on the confirmation content, or reset the param when the user leaves the per diem tab?
👁️ Written by AI, reviewed by Kevin.
There was a problem hiding this comment.
Removed the navigation.setParams call. The page now passes the target type only to the form it renders, as an overridden route (track when the draft is on the self DM, otherwise the route's iouType). The shared CREATE route keeps create, so the Manual and Scan tabs aren't affected.
| useEffect(() => { | ||
| if (hasRates || isOffline) { | ||
| return; | ||
| } | ||
| fetchPerDiemRates(policyID); | ||
| // Only refetch when coming back online. The fetch fills in the rates, which must not trigger another one. | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, [isOffline]); |
There was a problem hiding this comment.
🟡 The fetch only runs again when isOffline changes, so a policyID change while the gate is mounted never gets its rates.
In IOURequestStepPerDiem the policy comes from the transaction or report, and the report field can move the draft to another workspace while the gate stays mounted. If that workspace's rates aren't in Onyx yet, isLoading stays true and the whole form is stuck on the spinner.
Adding policyID to the deps still avoids refetching when the rates land:
}, [isOffline, policyID]);👁️ Written by AI, reviewed by Kevin.
There was a problem hiding this comment.
Done. Added policyID to the deps, so moving the draft to another workspace while the gate is mounted fetches that workspace's rates.
| <View style={[styles.mhn4]}> | ||
| <InputWrapperWithRef | ||
| InputComponent={ValuePicker} | ||
| InputComponent={ValueFieldDropdown} |
There was a problem hiding this comment.
🟡 The onOpen that blurred the quantity input went away with the ValuePicker swap, and ValueFieldDropdown doesn't dismiss the keyboard on its own.
On mobile, with Quantity focused, tapping Subrate now opens the dropdown (or the full page picker, which has shouldEnableKeyboardAvoidingView={false}) with the keyboard still up and covering part of the list.
Could ValueFieldDropdown take an onOpen callback that the subrate page uses to blur textInputRef, the way ValuePicker does?
👁️ Written by AI, reviewed by Kevin.
There was a problem hiding this comment.
Added an optional onOpen to ValueFieldDropdown, passed down to ExpenseFieldDropdown. It fires whichever way the list opens: in the container, full page, or the full page fallback when there's no room. The subrate page uses it to blur the Quantity input, like ValuePicker did.
| const draftCustomUnitID = transaction?.comment?.customUnit?.customUnitID; | ||
| const isDraftReady = isPerDiemRequest(transaction) && !!draftCustomUnitID && draftCustomUnitID !== CONST.CUSTOM_UNITS.FAKE_P2P_ID; | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
🟡 Please add tests for this draft setup effect. The new per diem form depends on it before anything renders.
The PR's tests cover the validation, getSubratesFields and the old routes. Nothing covers the pieces that changed behavior:
IOURequestStepPerDiem: a draft from global create, and one carryingFAKE_P2P_ID, get the custom unit, category, report and participants once the per diem draft settles, and stay on the loader until thenPerDiemRatesGate: loader, offline view and empty state, plus the fetch firing when rates are missingValueFieldDropdown: picking the selected item doesn't callonInputChange
👁️ Written by AI, reviewed by Kevin.
There was a problem hiding this comment.
Added:
tests/ui/IOURequestStepPerDiemTest.tsx: a global create draft and aFAKE_P2P_IDdraft both get the custom unit, category, report and participants, and stay on the loader until ready. Nothing is written before the tab switch rebuilds the draft as per diem. A self DM draft reaches the form astrackwithoutsetParams.tests/ui/PerDiemRatesGateTest.tsx: content with rates, loader plus fetch when they're missing, refetch whenpolicyIDchanges, offline view, empty state.tests/ui/ValueFieldDropdownTest.tsx: picking the selected item doesn't callonInputChange, picking another one does, andonOpenfires on open.
| value={subrateValue} | ||
| defaultValue={currentSubrate?.id} | ||
| items={validOptions} | ||
| sentryLabel={CONST.SENTRY_LABEL.REQUEST_CONFIRMATION_LIST.SUBRATE_FIELD} |
There was a problem hiding this comment.
🟢 This reuses the confirmation list's SUBRATE_FIELD label on a different element (the dropdown on the subrate page), so Sentry and FullStory can't tell the two apart.
Could we add a dedicated one, e.g. under CONST.SENTRY_LABEL.IOU_REQUEST_STEP, for the subrate dropdown?
👁️ Written by AI, reviewed by Kevin.
There was a problem hiding this comment.
Added a dedicated CONST.SENTRY_LABEL.IOU_REQUEST_STEP.PER_DIEM_SUBRATE_FIELD (IOURequestStep-PerDiemSubrateField) for the subrate page dropdown.
| /> | ||
| {/* Drawn as a bordered field so it lines up with the date inputs it sits between on the per diem time page. */} | ||
| <View ref={ref}> | ||
| <ExpenseFieldRow |
There was a problem hiding this comment.
🟢 The time row is a modified interactive element, so it needs a sentryLabel (see contributingGuides/SENTRY_LABEL.md).
TimeModalPicker could take a sentryLabel prop and pass it through to ExpenseFieldRow, with the time page passing separate start and end labels from CONST.SENTRY_LABEL.
👁️ Written by AI, reviewed by Kevin.
There was a problem hiding this comment.
PerDiemTimeField now requires a sentryLabel and passes it to ExpenseFieldRow. The time page passes IOURequestStep-PerDiemStartTimeField and IOURequestStep-PerDiemEndTimeField.
ikevin127
left a comment
There was a problem hiding this comment.
Found another blocker while manual testing 👇
| const reportPolicyID = getIOURequestPolicyID(transaction, report); | ||
| const policyID = reportPolicyID === CONST.POLICY.ID_FAKE ? getPolicyByCustomUnitID(transaction, allPolicies)?.id : reportPolicyID; | ||
| const [policy, policyMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${explicitPolicyID ?? policyID}`); | ||
| const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); |
There was a problem hiding this comment.
🔴 From global create with a single per diem workspace, this page can't resolve the policy and shows "Hmm... it's not here" instead of the destinations.
Screen.Recording.2026-11-02.at.17.04.02.mov
Steps to reproduce:
- Use an account with only one workspace that has per diem enabled and rates.
- Global create > Create expense > Per diem tab (the inline form opens, no workspace selector).
- Tap Destination.
- The RHP shows the not found page, and the verbose logs show
ManualNotFoundPageforcreate/create/start/1/<reportID>/per-diem.
The route reportID here is the global create placeholder, so getIOURequestPolicyID returns undefined. The getPolicyByCustomUnitID fallback only kicks in for ID_FAKE, so policy stays empty and shouldShowNotFoundPage fires.
Before this PR, the start page passed explicitPolicyID to this page. The inline form still gets it, but this page doesn't anymore.
IOURequestStepPerDiem sets customUnitID before the form renders, so falling back whenever the report gives no policy should fix it:
const policyID = !reportPolicyID || reportPolicyID === CONST.POLICY.ID_FAKE ? getPolicyByCustomUnitID(transaction, allPolicies)?.id : reportPolicyID;Please also check the time and subrate pages from the same flow. They get their policy from the same reportPolicyID through usePolicyForTransaction.
👁️ Written by AI, reviewed by Kevin.
There was a problem hiding this comment.
Thanks for the repro. DynamicIOURequestStepDestination now falls back to getPolicyByCustomUnitID whenever the route report has no policy, not only for ID_FAKE. For the time and subrate pages, usePolicyForTransaction now also falls back to the custom unit's policy for per diem requests when neither the report policy nor a draft policy resolves.
There was a problem hiding this comment.
Screen.Recording.2026-11-10.at.18.19.55.mov
trjExpensify
left a comment
There was a problem hiding this comment.
The behaviour here with two eligible workspace in the comment video looks a little off: #105421 (comment)
- Going back resolves to the same page (I think it should re-show that workspace picker screen. CC: @Expensify/design)
- The
Torow can't be changed on the confirmation page, which would avoid that back > change > re-do dance. If you do change the workspace here, we should clear the form.
|
Makes sense to me 👍 |
|
I also updated the behaviour with two eligible workspace cc @trjExpensify @dannymcclain @shawnborton @ikevin127 Screen.Recording.2026-11-10.at.18.28.58.mov |
|
Looks good to me. If we know one of these is your default workspace, can we default to selecting it? Assuming that's how that works... cc @trjExpensify |
|
@shawnborton Yes, currently, the behavior is auto selecting the default workspace |
ikevin127
left a comment
There was a problem hiding this comment.
Thanks for the updates, all of my earlier threads are fixed. Two 🟡 items are left: the rates gate doesn't follow the workspace picked in the "To" row, and the new Next footer also changes the time expense workspace picker. Please also fill in the Tests section, because QA runs them verbatim.
Request changes (non-blockers that should still be addressed)
|
On it now |
|
@ikevin127 I addressed all of your comments, could you please recheck? |
ikevin127
left a comment
There was a problem hiding this comment.
🟢 LGTM - ApproveD with one NAB comment.
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #105164 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
| const shouldShowOfflineView = !hasRates && isOffline; | ||
|
|
||
| useEffect(() => { | ||
| if (hasRates || isOffline) { |
There was a problem hiding this comment.
do we need to re-fetch if not offline to check for updates? Or do we assume the user has all of the rates up to date?
There was a problem hiding this comment.
No need to refetch when the rates are already there. Per diem rates live on the policy, so any edit an admin makes reaches members through the usual policy Onyx updates (Pusher / OpenApp / ReconnectApp), the same as categories and tags. We only fetch when the workspace has no rates loaded yet, which is also what the destination step did before this PR.
|
|
||
| if (isLoading) { | ||
| return ( | ||
| <ActivityIndicator |
There was a problem hiding this comment.
does this properly center it or do we need to put this in a view w/ flex 1 and justify center/items center
There was a problem hiding this comment.
It centers properly. React Native's ActivityIndicator wraps the spinner in a container that already has alignItems: center and justifyContent: center, so flex1 just lets it fill the space and the spinner sits in the middle. The destination step used this same markup before it moved into the gate.


Explanation of Change
Flattens the per diem flow so the per diem tab shows the expense form itself, with the destination, time and subrate as in-line fields, instead of walking the user through separate destination → time → subrate pages before the confirmation.
IOURequestStepPerDiem(new): the per diem tab content when the workspace is known. Before the form renders, it points the draft at the workspace (custom unit, default category, report, participants), which the destination step used to do. It shows a loader until the draft is ready. A draft that lands on the self DM goes to the form astrack. The type is passed only to the form, so theCREATEroute shared by every tab keeps itsiouType.PerDiemRatesGate(new): holds the form back until the workspace's per diem rates are loaded. It fetches them when missing, again whenever the workspace changes, and shows the offline view or the empty state otherwise.ValueFieldDropdown(new): a form field that opens its list in a container anchored to the field, falling back to the full page list when there's no room. Used by the subrate page, which blurs the Quantity input on open so the keyboard doesn't cover the list.PerDiemTimeField(new) andTimePickerModal(new): the per diem time page draws its time inputs as bordered fields that line up with the date inputs. The picker modal is shared withTimeModalPicker, which keeps its original menu row look, soVacationDelegateFormis unchanged.IOURequestStepPerDiemTest,PerDiemRatesGateTest,ValueFieldDropdownTest, plus updates to the existing per diem utils, validation and route tests.Fixed Issues
$ #105164
PROPOSAL:
Tests
Prerequisites: an account that belongs to two workspaces with per diem enabled (Workspace A and Workspace B), each with per diem rates that have at least one destination with two or more subrates. A third workspace with per diem enabled but no rates is needed for step 6.
Offline tests
QA Steps
Same as Tests, plus the Offline tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
Screen.Recording.2026-11-03.at.02.48.18.mov
MacOS: Chrome / Safari
Screen.Recording.2026-11-03.at.02.43.34.mov