<div>
    <ul class="list-group">
<?php
        $counter = 0;
        $root    = false;
        foreach ( $tasks as $task ) :
            $showStatus = true;
            if ( !$root ) {
                if ( $task['root'] ) {
                    $root = $task['rowId'];
                }
            }
            if ( 
                !$task['title'] || 
                strtolower($task['title']) == 'enter additional items' || 
                strtolower($task['title']) == 'daily log' || 
                str_contains(strtolower($task['title']), 'task list')
            ) {
                continue;
            }
?>
<?php
            if ( $counter == 1 && $task['parentId'] == $root) : 
?>
                <!-- <div id="taskList" class="collapse hide"> -->
<?php
            endif;
?>
            <li id="btb-task-<?php echo $task['id']; ?>" class="list-group-item d-flex justify-content-between <?php if ( $task['parentId'] == $root ) : $showStatus = false; ?>sticky-top text-light-emphasis bg-secondary-subtle fw-bold border-bottom border-danger-subtle border-top-0 border-start-0 border-end-0 rounded-top-0<?php endif; ?>" title="<?php echo $task['title']; ?>">
                <span class="d-inline-block text-truncate"><?php echo $task['title']; ?></span>
<?php
                    if ( $showStatus ) :
                        switch ( $task['status'] ) {
                            case 'N/A' :
                                $class = "text-bg-secondary";
                                break;
                            case 'Not Started' :
                                $class = "text-bg-danger";
                                break;
                            case 'Negotiating' :
                                $class = "text-bg-primary";
                                break;
                            case 'Scheduled' :
                                $class = "text-bg-info";
                                break;
                            case 'In Progress' :
                                $class = "text-bg-warning";
                                break;
                            case 'Completed' :
                                $class = "text-bg-success";
                                break;
                        }
?>
                <span class="badge rounded-pill <?php echo $class; ?> text-end py-2"><?php echo $task['status']; ?></span>
<?php
                    endif;
?>
                <?php if ( $task['parentId'] == $root && $counter > 0 ) : ?>
                    <!-- <span class="btn btn-link text-danger ms-auto p-0 taskListToggle btbAction" data-action="click" data-target="task list toggle" data-bs-toggle="collapse" data-bs-target="#taskList">Collapse</span> -->
                <?php endif; ?>
            </li>

<?php
            if ( $task['parentId'] == $root ) {
                $counter++;
            }
        endforeach;
?>
    </ul>
                <!-- closing div of the collapse element -->
                <!-- </div> -->
                <!-- closing div of the collapse element -->
            <!-- <div class="d-flex justify-content-end pt-2 pe-3 mb-5">
                <a class="text-danger taskListToggle" role="button" data-bs-toggle="collapse" data-bs-target="#taskList">Expand</a>
            </div> -->
</div>