Add in CommonFlow list

I have this function that returns all the orders from a restaurant:

suspend fun getRestaurantsProcessedOrdersWithThrowAndroid(): CommonFlow<List> {
realm.syncSession.downloadAllServerChanges()

    val userId = appService.currentUser

    if(appService.currentUser != null) {
        val restaurant = realm.query<Restaurant>("userID = $0", userId!!.id).first().find()!!
        return realm.query<ProcessedOrder>(
            "restaurantID = $0 and orderState != 'completed'",
            restaurant.getID()
        ).asFlow()
            .map {
                it.list
            }.asCommonFlow()
    }
    else{
        throw Exception("user not logged in")
    }

}

I want to change this function because a userId can have multiple restaurants (not just one!) and still send it using CommonFlow()?

I have tried like this, but it works only a new order is added. not when is updated? Is it because of the mutable list order? How I can change where I can add multiple CommonFlow lists?

It works just when adding new elements, not when updating or deleting:

suspend fun getRestaurantsProcessedOrdersWithThrowAndroid(): CommonFlow<List> {
realm.syncSession.downloadAllServerChanges()

    val userId = appService.currentUser

    if(appService.currentUser != null) {
        return realm.query<Restaurant>("userID = $0", userId!!.id).asFlow().map {
            val orders = mutableListOf<ProcessedOrder>()
            it.list.forEach { restaurant ->
                val thisOrder = realm.query<ProcessedOrder>(
                    "restaurantID = $0 and orderState != 'completed'",
                    restaurant.getID()
                ).find()
                orders.addAll(thisOrder)
            }
            orders
        }.asCommonFlow()
    }
    else{
        throw Exception("user not logged in")
    }

}

Have a great day!