Skip to content

[CFI] Flatten the Per Diem flow and use in-line fields - #105421

Open
thelullabyy wants to merge 15 commits into
Expensify:mainfrom
thelullabyy:fix/105164
Open

thelullabyy wants to merge 15 commits into
Expensify:mainfrom
thelullabyy:fix/105164

Conversation

@thelullabyy

@thelullabyy thelullabyy commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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 as track. The type is passed only to the form, so the CREATE route shared by every tab keeps its iouType.
  • 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) and TimePickerModal (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 with TimeModalPicker, which keeps its original menu row look, so VacationDelegateForm is unchanged.
  • The destination, time and subrate pages resolve the workspace from the draft's custom unit when the route report has none (global create with a single per diem workspace).
  • Removed the old chained destination/time/subrate routes and their go-back helpers. The standalone per diem confirmation, reached only from the workspace selector, now just pops back to the create page.
  • New Sentry labels for the per diem time and subrate fields.
  • Tests: 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.

  1. Form from a workspace chat
    1. Open Workspace A's chat > + > Create expense > Per diem tab.
    2. Verify the expense form opens straight away, with Destination, the start/end Time fields and Subrate as in-line fields (no separate destination → time → subrate pages).
    3. Tap Destination, pick one, and verify you go back to the form with the destination and its currency filled in.
    4. Set the start and end date/time and verify both fields show the picked times.
    5. Tap Subrate, verify the list opens anchored under the field (or as a full page on a small screen), pick a subrate and enter a quantity.
    6. Verify an empty Subrate row appears under the picked one while the destination still has unpicked subrates.
    7. Submit and verify the expense is created in Workspace A's chat with the right destination, dates, subrates and amount.
  2. Missing fields: Start a new per diem expense, leave Destination empty and tap Create expense. Verify an error shows on the missing field and nothing is submitted.
  3. Global create, several per diem workspaces
    1. Go to FAB > Create expense > Per diem tab.
    2. Verify the workspace list shows with a Next button at the bottom, and that tapping a row only marks it (it doesn't navigate).
    3. Mark Workspace B, tap Next, and verify the form opens for Workspace B.
    4. Go back, and verify the previously chosen workspace is still marked and Next continues without tapping it again.
  4. Global create, single per diem workspace: With an account that has only one per diem workspace, go to FAB > Create expense > Per diem tab. Verify the form opens directly for that workspace, with no workspace list.
  5. Changing the workspace in the "To" row
    1. Start a per diem expense on Workspace A and pick a destination and a subrate.
    2. Tap the To row and pick Workspace B.
    3. Verify the destination and subrates are cleared and the category resets to Workspace B's default per diem category.
    4. Tap Destination and verify the list shows Workspace B's destinations (not Workspace A's). If Workspace B's rates weren't loaded yet, verify a loader shows briefly and then the rates appear.
  6. Workspace without rates: Start a per diem expense on the workspace with no per diem rates. Verify the empty state shows, and as an admin verify the Edit per diem rates button opens the workspace's per diem settings.
  7. Time expense regression: Go to FAB > Create expense > Time tab on an account with several workspaces that have time tracking enabled. Verify that tapping a workspace row still moves on right away (no Next button).
  • Verify that no errors appear in the JS console

Offline tests

  1. Open a per diem expense on Workspace A once while online so its rates load, then go offline.
  2. Start a new per diem expense on Workspace A, fill in destination, time and subrate, and submit. Verify the expense is created and shown as pending, then go online and verify it syncs.
  3. While offline, start a per diem expense on a workspace whose rates were never loaded on this device. Verify the offline view shows instead of the form. Go online and verify the rates load and the form appears.

QA Steps

Same as Tests, plus the Offline tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

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

@melvin-bot

melvin-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

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.

Files with missing lines Coverage Δ
src/CONST/SENTRY_LABEL.ts 100.00% <ø> (ø)
src/ONYXKEYS.ts 100.00% <ø> (ø)
src/ROUTES.ts 35.01% <ø> (+0.09%) ⬆️
src/SCREENS.ts 100.00% <ø> (ø)
...tConfirmationList/hooks/useConfirmationListData.ts 98.96% <ø> (ø)
...onfirmationList/hooks/useConfirmationValidation.ts 93.90% <100.00%> (+0.15%) ⬆️
...estConfirmationList/hooks/useParticipantSection.ts 95.83% <100.00%> (ø)
...ConfirmationList/sections/ExpenseFieldDropdown.tsx 100.00% <100.00%> (ø)
...tConfirmationList/sections/ReportFieldDropdown.tsx 96.29% <100.00%> (-0.14%) ⬇️
src/components/TimeModalPicker.tsx 100.00% <100.00%> (+6.06%) ⬆️
... and 31 more
... and 8 files with indirect coverage changes

@thelullabyy
thelullabyy marked this pull request as ready for review November 2, 2026 19:25
@thelullabyy
thelullabyy requested review from a team as code owners November 2, 2026 19:25
@melvin-bot
melvin-bot Bot requested a review from ikevin127 November 2, 2026 19:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-02T19:44:45.298453Z
We couldn’t complete this review. Comment @codex review to try again.
ed1c9f1 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@melvin-bot
melvin-bot Bot removed the request for review from a team November 2, 2026 19:25
@melvin-bot

melvin-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

@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]

@melvin-bot
melvin-bot Bot requested review from trjExpensify and removed request for a team November 2, 2026 19:25
@ikevin127

ikevin127 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native
screen-20261102-172924-1793669251136.mp4
MacOS: Chrome / Safari
Screen.Recording.2026-11-02.at.16.47.27.mov

@ikevin127 ikevin127 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.md to cover the ValueFieldDropdown addition to ValidInputs

),
);
// 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));

@ikevin127 ikevin127 Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 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.

⚠️ Reproduced it locally: back from the confirmation lands on the create page locked to the workspace I first picked, with no way to choose another one, unless the create expense flow is restarted.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/components/TimeModalPicker.tsx Outdated
Comment on lines +54 to +61
<View ref={ref}>
<ExpenseFieldRow
name={label}
value={currentTime}
onPress={() => setIsPickerVisible(true)}
errorText={errorText}
/>
</View>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +88 to +90
if (targetIouType !== iouType) {
navigation.setParams({iouType: targetIouType});
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +56 to +63
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]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 carrying FAKE_P2P_ID, get the custom unit, category, report and participants once the per diem draft settles, and stay on the loader until then
  • PerDiemRatesGate: loader, offline view and empty state, plus the fetch firing when rates are missing
  • ValueFieldDropdown: picking the selected item doesn't call onInputChange

👁️ Written by AI, reviewed by Kevin.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added:

  • tests/ui/IOURequestStepPerDiemTest.tsx: a global create draft and a FAKE_P2P_ID draft 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 as track without setParams.
  • tests/ui/PerDiemRatesGateTest.tsx: content with rates, loader plus fetch when they're missing, refetch when policyID changes, offline view, empty state.
  • tests/ui/ValueFieldDropdownTest.tsx: picking the selected item doesn't call onInputChange, picking another one does, and onOpen fires on open.

value={subrateValue}
defaultValue={currentSubrate?.id}
items={validOptions}
sentryLabel={CONST.SENTRY_LABEL.REQUEST_CONFIRMATION_LIST.SUBRATE_FIELD}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a dedicated CONST.SENTRY_LABEL.IOU_REQUEST_STEP.PER_DIEM_SUBRATE_FIELD (IOURequestStep-PerDiemSubrateField) for the subrate page dropdown.

Comment thread src/components/TimeModalPicker.tsx Outdated
/>
{/* 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PerDiemTimeField now requires a sentryLabel and passes it to ExpenseFieldRow. The time page passes IOURequestStep-PerDiemStartTimeField and IOURequestStep-PerDiemEndTimeField.

@ikevin127 ikevin127 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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:

  1. Use an account with only one workspace that has per diem enabled and rates.
  2. Global create > Create expense > Per diem tab (the inline form opens, no workspace selector).
  3. Tap Destination.
  4. The RHP shows the not found page, and the verbose logs show ManualNotFoundPage for create/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen.Recording.2026-11-10.at.18.19.55.mov

@trjExpensify trjExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 To row 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.

@dannymcclain

Copy link
Copy Markdown
Contributor

Agree with that Tom. I also think we need a footer button on this screen (and to not advance on selection):

image

It's pretty confusing to me how to even continue with Media in that screenshot since it was preselected.

@shawnborton

Copy link
Copy Markdown
Contributor

Makes sense to me 👍

@thelullabyy

Copy link
Copy Markdown
Contributor Author

I also updated the behaviour with two eligible workspace

cc @trjExpensify @dannymcclain @shawnborton @ikevin127

Screen.Recording.2026-11-10.at.18.28.58.mov

@shawnborton

Copy link
Copy Markdown
Contributor

Looks good to me. If we know one of these is your default workspace, can we default to selecting it?
CleanShot 2026-11-10 at 11 31 08 AM@2x

Assuming that's how that works... cc @trjExpensify

@thelullabyy

Copy link
Copy Markdown
Contributor Author

@shawnborton Yes, currently, the behavior is auto selecting the default workspace

@ikevin127 ikevin127 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@thelullabyy

Copy link
Copy Markdown
Contributor Author

On it now

@thelullabyy

Copy link
Copy Markdown
Contributor Author

@ikevin127 I addressed all of your comments, could you please recheck?

@ikevin127 ikevin127 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 LGTM - ApproveD with one NAB comment.

Comment thread tests/ui/IOURequestStepPerDiemTest.tsx Resolved
@melvin-bot

melvin-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this properly center it or do we need to put this in a view w/ flex 1 and justify center/items center

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants