[AsyncHybridViewInflation] Fix crash in Historic Message handling

groupMessages throws ArrayIndexOutOfBoundsException when there is historic message.
This CL make this change inline with the logic in ConversationLayout.

Bug: 217799515
Test: check Add Historic for MessagingStyle Notification and add notification. Observe no crash
Flag: ACONFIG notification_async_hybrid_view_inflation DEVELOPMENT
Change-Id: Ic2c1d8d5bf1df209a876168469e0e82fe0225f1e
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/SingleLineViewInflater.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/SingleLineViewInflater.kt
index d3c874c..3fce9ce 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/SingleLineViewInflater.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/SingleLineViewInflater.kt
@@ -217,8 +217,9 @@
         var currentGroup: MutableList<MessagingStyle.Message>? = null
         var currentSenderKey: CharSequence? = null
         val groups = mutableListOf<MutableList<MessagingStyle.Message>>()
-        for (i in 0 until (historicMessages.size + messages.size)) {
-            val message = if (i < historicMessages.size) historicMessages[i] else messages[i]
+        val histSize = historicMessages.size
+        for (i in 0 until (histSize + messages.size)) {
+            val message = if (i < histSize) historicMessages[i] else messages[i - histSize]
 
             val sender = message.senderPerson
             val senderKey = sender?.getKeyOrName()