Repository navigation
Closed
Labels
Awaiting PaymentAuto-added when associated PR is deployed to productionAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.Something is broken. Auto assigns a BugZero manager.DailyKSv2KSv2ExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributor
Description
Context
This issue tracks part 1 of the ManualSubmitToDestinationVisible work (submit → destination visible telemetry and performance). It corresponds to the refactor delivered in PR #87963.
Goal
Prepare and instrument the submit-to-destination flow without changing intended product behavior: consolidate orchestration and telemetry so follow-up changes (dismiss-first fast paths) can land safely.
What shipped in #87963
SubmitExpenseOrchestrator— Extracts the submit decision tree (including GPS permission handling and telemetry lifecycle) fromIOURequestStepConfirmationinto a dedicated render-prop component. Only the default slow path is active in this PR.- Centralized telemetry in
submitFollowUpAction.ts— Single place for tracking session management (startTracking,setFastPath,addOptimization,cancelTracking), follow-up action state, and structured__DEV__logging (e.g.[SubmitExpense] request_money_manual -> navigate_to_search (none) 105ms [slow path]). isTracking()— Replaces scatteredgetSpan()checks in navigation helpers and IOU actions where appropriate.useEndSubmitNavigationSpans— Shared hook for span-ending logic previously duplicated inSearchPageNarrowandSearchPageWide.- Bugfix — Clear
trackingStatewhencancelSubmitFollowUpActionSpanruns so telemetry state stays consistent.
Out of scope (follow-up)
- Dismiss-first navigation fast paths and
[fast path]labeling are intentionally deferred to PR #87768 (HOLD on [Performance] Refactor: Extract SubmitExpenseOrchestrator + centralize telemetry #87963).
Acceptance criteria
- All expense submit flows behave as before (including distance + GPS permission).
- Telemetry lifecycle is centralized; in dev, console shows structured
[SubmitExpense]lines after submit. - No regressions in navigation after expense creation (Search, Inbox report, RHP, modal dismiss paths).
Links
- Parent epic: ManualSubmitToDestinationVisible - Measure end-to-end time from expense creation submit to destination page render #83634
- Implementation PR: [Performance] Refactor: Extract SubmitExpenseOrchestrator + centralize telemetry #87963
- Follow-up PR: [Performance] Extend dismiss-first navigation fast paths + deferred writes #87768
Issue Owner
Current Issue Owner: @mallenexpensifyUpwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022044561206615367758
- Upwork Job ID: 2044561206615367758
- Last Price Increase: 2026-04-15
Metadata
Metadata
Labels
Awaiting PaymentAuto-added when associated PR is deployed to productionAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.Something is broken. Auto assigns a BugZero manager.DailyKSv2KSv2ExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributor
Activity
MelvinBot commentedon Apr 15, 2026
Issue Analysis
Status: PR #87963 is open with all 32 CI checks passing. It has one approval from
ShridharGoeland a pending review request frommountiny.Root Cause (of any delay): This is a tracking issue for a planned refactor, not a bug. The implementation PR is code-complete and CI-green — it's awaiting final review.
PR #87963 Code Review Summary: The refactor is clean and behavior-preserving. No bugs found. Specifically:
SubmitExpenseOrchestratorcorrectly extracts the submit decision tree (GPS permission flow, telemetry, confirm logic) fromIOURequestStepConfirmationinto a render-prop componentstartTracking,isTracking,cancelTracking) replaces 4 scatteredstartSpancallsites and keeps span/state in syncuseEndSubmitNavigationSpansdeduplicates span-ending logic fromSearchPageNarrow/SearchPageWidewith a minor improvement:DISMISS_MODAL_ONLYskips the layout gate on narrow (page already mounted)trackingStateon cancel is correctshouldHandleNavigationparameter threaded through all expense creation functions defaults totrue, preserving current behaviorOne minor note for follow-up
Between this PR merging and PR #87768, the pre-insert search route
useEffectstill fires on narrow layout but the fast path that would use it on confirm is removed. This is harmless —removePreInsertedFullscreenIfNeededhandles cleanup on unmount — but worth keeping in mind during Part 2 review.Acceptance criteria assessment: All three criteria from the issue appear met by the PR:
[SubmitExpense]dev logging ✓Next Steps: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.melvin-bot commentedon Apr 15, 2026
Current assignee @ShridharGoel is eligible for the External assigner, not assigning anyone new.
[-][Metrics] ManualSubmitToDestinationVisible — SubmitExpenseOrchestrator + centralized telemetry (part 1)[/-][+][$250] [Metrics] ManualSubmitToDestinationVisible — SubmitExpenseOrchestrator + centralized telemetry (part 1)[/+]melvin-bot commentedon Apr 15, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022044561206615367758
yuvrajangadsingh commentedon Apr 15, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
Submit-to-destination telemetry is scattered across multiple files.
IOURequestStepConfirmationowns the submit decision tree, GPS permission flow, and telemetry span lifecycle all in one 1500+ line component. Span checks (getSpan()) are duplicated in navigation helpers and search pages. This scatter makes it fragile to add fast-path optimizations and leaves a bug wheretrackingStateisn't cleared on cancel.What is the root cause of that problem?
Three things are tangled together in
IOURequestStepConfirmation.tsx:Telemetry span management is inline.
startSpan(SPAN_SUBMIT_EXPENSE)at line 1057, thenmarkSubmitExpenseEnd()called 17 separate times across every branch ofcreateTransaction(lines 1074, 1121, 1157, 1191, 1213, 1226, 1236, 1242, 1250, 1254, 1260, 1278, 1288, 1294, 1302, 1307). Each branch must remember to close the span or it leaks.Span existence checks are scattered.
dismissModalAndOpenReportInInboxTab.tschecksgetSpan(SPAN_SUBMIT_TO_DESTINATION_VISIBLE)to decide whether to set follow-up actions.Split.tsdoes the same at line 2292. These should use a singleisTracking()API rather than reaching into raw span state.Span-ending logic is duplicated.
SearchPageNarrow(lines 188-212) andSearchPageWide(lines 64-73) both implement their own callback for ending submit navigation spans, with slightly different gating logic (narrow needs focus+layout dual-gate, wide doesn't).Bug:
cancelSubmitFollowUpActionSpan()insubmitFollowUpAction.tscancels the Sentry span and clearspendingSubmitFollowUpAction, but doesn't cleartrackingState. If a user cancels mid-flow and starts a new submit, stale tracking state pollutes the next session's telemetry.What changes do you think we should make in order to solve the problem?
Affected surfaces: 12 source files + 5 test files.
New files (2):
src/pages/iou/request/step/confirmation/SubmitExpenseOrchestrator.tsx- Render-prop component that extracts submit orchestration from IOURequestStepConfirmation. OwnsisConfirming,selectedParticipantList, andstartLocationPermissionFlowstate. CallsstartTracking()+setFastPath(DEFAULT)beforecreateTransaction(). RendersLocationPermissionModalconditionally. Only the default (slow) path is active; fast-path handlers are deferred to PR [Performance] Extend dismiss-first navigation fast paths + deferred writes #87768.src/hooks/useEndSubmitNavigationSpans.ts- Shared hook replacing duplicated span-ending logic. Takes{requireLayout: boolean}. Narrow layout (requireLayout: true) dual-gates on focus+layout signals, with a carve-out forDISMISS_MODAL_ONLYwhere focus alone suffices (page already mounted). Wide layout (requireLayout: false) ends immediately on any signal.Modified files (10):
src/libs/telemetry/submitFollowUpAction.ts- AddTrackingStatemodule-level state,startTracking()(replaces scatteredstartSpancalls, starts bothSPAN_SUBMIT_EXPENSEandSPAN_SUBMIT_TO_DESTINATION_VISIBLE),setFastPath()(write-once per session),addOptimization(),cancelTracking(),isTracking(). InendSubmitFollowUpActionSpan, emit structured__DEV__log like[SubmitExpense] request_money_manual -> navigate_to_search (none) 105ms [slow path]. Bugfix: settrackingState = nullinsidecancelSubmitFollowUpActionSpan.src/CONST/index.ts- AddATTRIBUTE_FAST_PATH_HANDLER,FAST_PATH_HANDLERenum (search_pre_insert, report_pre_insert, dismiss_modal, etc.),SUBMIT_OPTIMIZATIONenum (pre_insert, dismiss_first, deferred_write).src/pages/iou/request/step/IOURequestStepConfirmation.tsx- RemovestartLocationPermissionFlow,selectedParticipantList,isConfirmingstate,startSubmitSpans(),onConfirm(), andLocationPermissionModalJSX. WrapMoneyRequestConfirmationListinSubmitExpenseOrchestratorrender prop. ThreadshouldHandleNavigationparameter throughrequestMoney,trackExpense,submitPerDiemExpense,createDistanceRequest, and intocreateTransaction.src/pages/Search/SearchPageNarrow/index.tsx- Replace 28-line inlineendSubmitNavigationSpanscallback withuseEndSubmitNavigationSpans({requireLayout: true}).src/pages/Search/SearchPageWide.tsx- Replace 12-line inline callback withuseEndSubmitNavigationSpans({requireLayout: false}).src/libs/Navigation/helpers/dismissModalAndOpenReportInInboxTab.ts- ReplacegetSpan(SPAN_SUBMIT_TO_DESTINATION_VISIBLE)withisTracking()from submitFollowUpAction. Four callsites.src/libs/actions/IOU/Split.ts- ReplacegetSpan()withisTracking()at the split bill navigation check.src/libs/actions/IOU/SendMoney.ts- Replace twostartSpan(SPAN_SUBMIT_TO_DESTINATION_VISIBLE)calls (sendMoneyElsewhere, sendMoneyWithWallet) withstartTracking(), passing{skipSubmitExpenseSpan: true}since send-money flows don't need the submit expense span.src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx- ReplacestartSpan()withstartTracking()for invoice company info submit.src/libs/Navigation/Navigation.ts- ExportgetPreInsertedFullscreenRouteName()(needed by follow-up PR but wired here).Test updates (5): Update mocks in
GoogleTagManagerTest,dismissModalAndOpenReportInInboxTabTest,navigateAfterExpenseCreateTest,TimeExpenseConfirmationTest,IOURequestStepConfirmationPageTestto useisTrackingmock instead ofgetSpanmock, and addgetPreInsertedFullscreenRouteNameto Navigation mocks.This is all behavior-preserving. The only active path is
FAST_PATH_HANDLER.DEFAULT(slow path). Fast-path dismiss-first handlers land in the follow-up PR.What alternative solutions did you explore? (Optional)
A custom hook instead of a render-prop component for SubmitExpenseOrchestrator was considered, but the orchestrator needs to conditionally render
LocationPermissionModalJSX. A hook can't own JSX, so it would push modal placement back to the parent, splitting the concern across two files again. The render-prop pattern keeps everything self-contained.5 remaining items
melvin-bot commentedon Apr 23, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.61-4 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 2026-04-30. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Apr 23, 2026
@ShridharGoel The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
melvin-bot commentedon Apr 27, 2026
@ShridharGoel Eep! 4 days overdue now. Issues have feelings too...
melvin-bot commentedon Apr 30, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Apr 30, 2026
@ShridharGoel you do payment here.. .now?
ShridharGoel commentedon May 1, 2026
@mallenexpensify Yes, this should be ready for payment. Doesn't need a BZ checklist since it was related to perf improvement and no functionality changes.
mallenexpensify commentedon May 1, 2026
Payment Summary
Contributor+: @ShridharGoel due $250 via NewDot
garrettmknight commentedon May 5, 2026
$250 approved for @ShridharGoel