this is the controller for message view:

	public function actionView(int $id): Response|string
	{
		$model = $this->findModel($id);
		$replyForm = new ReplyForm($model->id);
		//$replyForm = new ReplyForm($model);// Dependency injection.
		$request = \Yii::$app->request;
		if (($request->isPost) && ($replyForm->load($request->post()))) {
			
			// Check that Form status is not STATUS_REPLIED, this status should not be manually set via a form.
			$inputStatus = (int)$replyForm->status;
			if ($inputStatus !== Message::STATUS_REPLIED) {
				
				// Check that current model status is not STATUS_REPLIED and a reply hasn't been set.
				if (($model->status !== Message::STATUS_REPLIED) && (ValueHelper::isSetAndNull($model->replied))) {
				
					// Determine if a reply has been provided via the form.
					$getReply = ValueHelper::isSetNotNull($replyForm->reply);
					
					// Check if the status has changed from the original model status.
					$getStatus = $replyForm->status !== $model->status;
					
					// Determine scenario based on form changes.
					if ($getReply && $getStatus) {
					
						$replyForm->scenario = 'both';
					}
					elseif ($getReply) {
					
						$replyForm->scenario = 'replyOnly';
					}
					elseif ($getStatus) {
					
						$replyForm->scenario = 'statusOnly';
					}
				}
				// Only status change is possible if replied is set.
				else {
					$replyForm->scenario = 'statusOnly';
				}
			}
			
			// Use the selected scenario to validate form and process.
			if ($replyForm->validate()) {
			
				// Double-check that STATUS_REPLIED is not being saved.
				if ($inputStatus !== Message::STATUS_REPLIED) {
					
					if ($replyForm->process()) {
						
						$this->setScenarioSuccessFlash($replyForm->scenario, $model);
						
						return $this->redirect(['index']);
					}
					else {
						// Note: Error logging is handled within form Model(s) and user-facing error messages wthin the controller.
						$msg = \Yii::t('app', 'There was an error processing your request. Please try again.');
						\Yii::$app->session->setFlash('error', $msg);
					}
				}
				// If trying to save $status as STATUS_REPLIED, give error.
				else {
					$msg = \Yii::t('app', 'Cannot save status to replied.');
					\Yii::$app->session->setFlash('error', $msg);
				}
			}
			else {
				// Validation failed.
				$msg = \Yii::t('app', 'There was a validation error. Please check your input.');
				\Yii::$app->session->setFlash('error', $msg);
			}
		}
		
		// First time viewing Message, change status to Read.
		if (($request->isGet) && ($model->status === Message::STATUS_UNREAD)) {
		
			$model->addStatus(Message::STATUS_READ);
			$model->save(false);
		}
		
		// Fetch replies for the message.
		$replies = $model->getReplies()->all();
		
		return $this->render('view', [
			'model' => $model,
			'replyForm' => $replyForm,
			'replies' => $replies,
		]);
	}
	
	private function setScenarioSuccessFlash(string $scenario, $model): void
	{
		switch ($scenario) {
			case 'statusOnly' :
				$msg = \Yii::t('app', 'The status for {to} has been updated.', ['to' => $model->email]);
				break;
			case 'replyOnly' :
			case 'both' :
			default :
				$msg = \Yii::t('app', 'Your reply to {to} has been sent.', ['to' => $model->email]);
				break;
		}
		
		\Yii::$app->session->setFlash('success', $msg);
	}
}


This is my orignal message view file code:

<div class="card admin-card">
<div class="card-header admin-card-header">
<h5 class="mb-0"><?= Html::encode($this->title) . ' (ID: ' . Html::encode($model->id) . ')'; ?></h5></div>
<div class="card-body admin-card-body">
<div class="form-container">

<div class="reply-form-status">
<?php
// Prepare status options for the form.
$currentStatus = $model->status;
// Define available options
$statusOptions = [
	Message::STATUS_UNREAD => 'Unread',
	Message::STATUS_READ => 'Read',
	Message::STATUS_IMPORTANT => 'Important',
	Message::STATUS_SPAM => 'Spam',
];

// Include STATUS_REPLIED in options only if it's the current status.
if ($currentStatus === Message::STATUS_REPLIED) {
	$statusOptions[Message::STATUS_REPLIED] = 'Replied';
}

echo $form->field($replyForm, 'status')->dropDownList($statusOptions, [
	'options' => [$currentStatus => ['Selected' => true]],
	'prompt' => \Yii::t('app', 'Select a status...'),
])->hint(\Yii::t('app', 'required'));
?>
</div><!-- .reply-form-status -->

<div class="card">
<div class="card-header">
<?php /*<h3 class="mt-0"><?= Html::encode($this->title); ?></h3>*/ ?>
<h6 class="font-italic"><?= \Yii::t('app', 'Sent on: ') . $formatter->asDatetime($model->created_at, 'medium'); ?></h6>
<h6><?= \Yii::t('app', 'Sent by: ') . Html::encode($model->email); ?></h6>
<?php $ip = ($model->created_ip) ? $model->created_ip : '(not set)'; ?>
<h6><?= \Yii::t('app', 'IP: ') . $ip; ?></h6>
<hr>
<h6><?= \Yii::t('app', 'Subject: ') . Html::encode($model->subject); ?></h6>
</div><!-- .cart-header -->

<div class="card-body m-3 p-0">
<?= Html::encode($model->body); ?>
</div><!-- .card-body .p-0 -->
</div><!-- .card -->


<?php if (ValueHelper::isSetAndNull($model->replied) && $model->status !== Message::STATUS_REPLIED) : ?>
<div class="reply-form-reply mt-3 ms-3">
<?= $form->field($replyForm, 'reply')->textarea(['rows' => 6])->label('Send a reply:'); ?>
</div><!-- .reply-form-reply -->


<?php else : ?>

<?php /**
TODO THIS NEEDS TO BE CHANGED INTO THE FOREACH LOOP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/ ?>

<div class="reply-form-reply mt-3 ms-3">
<div class="card">
<div class="card-header">
<h6 class="font-italic"><?= \Yii::t('app', 'Replied on: ') . $formatter->asDatetime($model->repliedTime, 'medium'); ?></h6>
</div><!-- .cart-header -->
<div class="card-body m-3 p-0">
<?= Html::encode($model->replied); ?>
</div><!-- .card-body .p-0 -->
</div><!-- .card -->
</div><!-- .reply-form-reply -->


<?php endif; ?>
</div><!-- .form-container -->
</div><!-- .card-body -->
</div><!-- .card -->


I need to change it to work with the following changes witihn my message model:

class Message extends ActiveRecord
{
	const STATUS_UNREAD = 1;// 0b00001
	const STATUS_READ = 2;// 0b00010
	const STATUS_IMPORTANT = 4;// 0b00100
	const STATUS_RESOLVED = 8;// 0b01000
	const STATUS_SPAM = 16;// 0b10000
	const STATUS_ARCHIVED = 32;// 0b100000
	const STATUS_FLAGGED = 64;// 0b110000
	
	public function setStatusFromCheckboxes($checkboxes): void
	{
		$this->status = 0;
		foreach ($checkboxes as $value) {
			
			$this->addStatus((int)$value);
		}
	}
	
	public function addStatus($status): void
	{
		$this->status |= $status;
	}
	
	public function removeStatus($status): void
	{
		$this->status &= ~$status;
	}
	
	public function hasStatus($status): bool
	{
		
		return ($this->status & $status) === $status;
	}
	
	public function getReplies(): MessageQuery
	{
		return $this->hasMany(self::class, ['parent_id' => 'id']);
	}
}

Was thinking of adding something like the following code into the view so i could see the list of replies:

<div class="card admin-card">
    <div class="card-header admin-card-header">
        <h5 class="mb-0"><?= Html::encode($this->title) . ' (ID: ' . Html::encode($model->id) . ')'; ?></h5>
    </div>
    <div class="card-body admin-card-body">
        <div class="form-container">

            <!-- Status and existing message details (your existing code) -->

            <!-- Existing reply form logic here... -->

        </div><!-- .form-container -->

        <!-- Displaying Replies -->
        <div class="replies-container mt-4">
            <h6><?= \Yii::t('app', 'Replies:') ?></h6>
            <?php if (empty($replies)) : ?>
                <p><?= \Yii::t('app', 'No replies yet.') ?></p>
            <?php else : ?>
                <ul class="list-unstyled">
                    <?php foreach ($replies as $reply) : ?>
                        <li class="reply-item">
                            <div class="card">
                                <div class="card-header">
                                    <h6 class="font-italic"><?= \Yii::t('app', 'Replied on: ') . $formatter->asDatetime($reply->created_at, 'medium'); ?></h6>
                                </div>
                                <div class="card-body">
                                    <?= Html::encode($reply->body); ?>
                                </div>
                            </div>
                        </li>
                    <?php endforeach; ?>
                </ul>
            <?php endif; ?>
        </div><!-- .replies-container -->
    </div><!-- .card-body -->
</div><!-- .card -->