File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -213,19 +213,20 @@ function ReportActionsList({
213213 return sortedVisibleReportActions ;
214214 }
215215
216- let insertIndex = sortedVisibleReportActions . length ;
217216 // Insert the synthetic draft into the already-descending render list without treating it as a persisted report action.
218217 for ( const [ index , action ] of sortedVisibleReportActions . entries ( ) ) {
219218 if ( action . reportActionID === draftReportAction . reportActionID ) {
220219 return sortedVisibleReportActions ;
221220 }
222- if ( insertIndex === sortedVisibleReportActions . length && isNewerReportAction ( draftReportAction , action ) ) {
223- insertIndex = index ;
221+ if ( isNewerReportAction ( draftReportAction , action ) ) {
222+ const visibleReportActionsWithDraft = [ ...sortedVisibleReportActions ] ;
223+ visibleReportActionsWithDraft . splice ( index , 0 , draftReportAction ) ;
224+ return visibleReportActionsWithDraft ;
224225 }
225226 }
226227
227228 const visibleReportActionsWithDraft = [ ...sortedVisibleReportActions ] ;
228- visibleReportActionsWithDraft . splice ( insertIndex , 0 , draftReportAction ) ;
229+ visibleReportActionsWithDraft . push ( draftReportAction ) ;
229230 return visibleReportActionsWithDraft ;
230231 } , [ draftReportAction , sortedVisibleReportActions ] ) ;
231232 const draftMessageHTML = draftReportAction ? getReportActionMessage ( draftReportAction ) ?. html : undefined ;
You can’t perform that action at this time.
0 commit comments