@@ -5,7 +5,9 @@ import FormHelpMessage from '@components/FormHelpMessage';
5
5
import useLocalize from '@hooks/useLocalize' ;
6
6
import useThemeStyles from '@hooks/useThemeStyles' ;
7
7
import { READ_COMMANDS } from '@libs/API/types' ;
8
+ import * as Browser from '@libs/Browser' ;
8
9
import DistanceRequestUtils from '@libs/DistanceRequestUtils' ;
10
+ import getPlatform from '@libs/getPlatform' ;
9
11
import HttpUtils from '@libs/HttpUtils' ;
10
12
import * as IOUUtils from '@libs/IOUUtils' ;
11
13
import Navigation from '@libs/Navigation/Navigation' ;
@@ -15,9 +17,11 @@ import MoneyRequestParticipantsSelector from '@pages/iou/request/MoneyRequestPar
15
17
import * as IOU from '@userActions/IOU' ;
16
18
import CONST from '@src/CONST' ;
17
19
import ONYXKEYS from '@src/ONYXKEYS' ;
20
+ import type { Route } from '@src/ROUTES' ;
18
21
import ROUTES from '@src/ROUTES' ;
19
22
import type SCREENS from '@src/SCREENS' ;
20
23
import type { Participant } from '@src/types/onyx/IOU' ;
24
+ import KeyboardUtils from '@src/utils/keyboard' ;
21
25
import StepScreenWrapper from './StepScreenWrapper' ;
22
26
import type { WithFullTransactionOrNotFoundProps } from './withFullTransactionOrNotFound' ;
23
27
import withFullTransactionOrNotFound from './withFullTransactionOrNotFound' ;
@@ -37,7 +41,7 @@ function IOURequestStepParticipants({
37
41
const { translate} = useLocalize ( ) ;
38
42
const styles = useThemeStyles ( ) ;
39
43
const isFocused = useIsFocused ( ) ;
40
- const [ skipConfirmation ] = useOnyx ( `${ ONYXKEYS . COLLECTION . SKIP_CONFIRMATION } ${ transactionID ?? - 1 } ` ) ;
44
+ const [ skipConfirmation ] = useOnyx ( `${ ONYXKEYS . COLLECTION . SKIP_CONFIRMATION } ${ transactionID ?? CONST . DEFAULT_NUMBER_ID } ` ) ;
41
45
42
46
// We need to set selectedReportID if user has navigated back from confirmation page and navigates to confirmation page with already selected participant
43
47
const selectedReportID = useRef < string > ( participants ?. length === 1 ? participants . at ( 0 ) ?. reportID ?? reportID : reportID ) ;
@@ -70,6 +74,8 @@ function IOURequestStepParticipants({
70
74
const receiptFilename = transaction ?. filename ;
71
75
const receiptPath = transaction ?. receipt ?. source ;
72
76
const receiptType = transaction ?. receipt ?. type ;
77
+ const isAndroidNative = getPlatform ( ) === CONST . PLATFORM . ANDROID ;
78
+ const isMobileSafari = Browser . isMobileSafari ( ) ;
73
79
74
80
// When the component mounts, if there is a receipt, see if the image can be read from the disk. If not, redirect the user to the starting step of the flow.
75
81
// This is because until the expense is saved, the receipt file is only stored in the browsers memory as a blob:// and if the browser is refreshed, then
@@ -86,7 +92,7 @@ function IOURequestStepParticipants({
86
92
( val : Participant [ ] ) => {
87
93
HttpUtils . cancelPendingRequests ( READ_COMMANDS . SEARCH_FOR_REPORTS ) ;
88
94
89
- const firstParticipantReportID = val . at ( 0 ) ?. reportID ?? '' ;
95
+ const firstParticipantReportID = val . at ( 0 ) ?. reportID ;
90
96
const rateID = DistanceRequestUtils . getCustomUnitRateID ( firstParticipantReportID ) ;
91
97
const isInvoice = iouType === CONST . IOU . TYPE . INVOICE && ReportUtils . isInvoiceRoomWithID ( firstParticipantReportID ) ;
92
98
numberOfParticipants . current = val . length ;
@@ -102,11 +108,24 @@ function IOURequestStepParticipants({
102
108
}
103
109
104
110
// When a participant is selected, the reportID needs to be saved because that's the reportID that will be used in the confirmation step.
105
- selectedReportID . current = firstParticipantReportID || reportID ;
111
+ selectedReportID . current = firstParticipantReportID ?? reportID ;
106
112
} ,
107
113
[ iouType , reportID , transactionID ] ,
108
114
) ;
109
115
116
+ const handleNavigation = useCallback (
117
+ ( route : Route ) => {
118
+ if ( isAndroidNative || isMobileSafari ) {
119
+ KeyboardUtils . dismiss ( ) . then ( ( ) => {
120
+ Navigation . navigate ( route ) ;
121
+ } ) ;
122
+ } else {
123
+ Navigation . navigate ( route ) ;
124
+ }
125
+ } ,
126
+ [ isAndroidNative , isMobileSafari ] ,
127
+ ) ;
128
+
110
129
const goToNextStep = useCallback ( ( ) => {
111
130
const isCategorizing = action === CONST . IOU . ACTION . CATEGORIZE ;
112
131
const isShareAction = action === CONST . IOU . ACTION . SHARE ;
@@ -132,12 +151,13 @@ function IOURequestStepParticipants({
132
151
transactionID ,
133
152
selectedReportID . current || reportID ,
134
153
) ;
135
- if ( isCategorizing ) {
136
- Navigation . navigate ( ROUTES . MONEY_REQUEST_STEP_CATEGORY . getRoute ( action , iouType , transactionID , selectedReportID . current || reportID , iouConfirmationPageRoute ) ) ;
137
- } else {
138
- Navigation . navigate ( iouConfirmationPageRoute ) ;
139
- }
140
- } , [ iouType , transactionID , transaction , reportID , action , participants ] ) ;
154
+
155
+ const route = isCategorizing
156
+ ? ROUTES . MONEY_REQUEST_STEP_CATEGORY . getRoute ( action , iouType , transactionID , selectedReportID . current || reportID , iouConfirmationPageRoute )
157
+ : iouConfirmationPageRoute ;
158
+
159
+ handleNavigation ( route ) ;
160
+ } , [ action , participants , iouType , transaction , transactionID , reportID , handleNavigation ] ) ;
141
161
142
162
const navigateBack = useCallback ( ( ) => {
143
163
IOUUtils . navigateToStartMoneyRequestStep ( iouRequestType , iouType , transactionID , reportID , action ) ;
@@ -154,7 +174,8 @@ function IOURequestStepParticipants({
154
174
IOU . setCustomUnitRateID ( transactionID , rateID ) ;
155
175
IOU . setMoneyRequestParticipantsFromReport ( transactionID , selfDMReport ) ;
156
176
const iouConfirmationPageRoute = ROUTES . MONEY_REQUEST_STEP_CONFIRMATION . getRoute ( action , CONST . IOU . TYPE . TRACK , transactionID , selfDMReportID ) ;
157
- Navigation . navigate ( iouConfirmationPageRoute ) ;
177
+
178
+ handleNavigation ( iouConfirmationPageRoute ) ;
158
179
} ;
159
180
160
181
useEffect ( ( ) => {
0 commit comments