`visible()` doesn't resolve record

I have the following Table

public function table(Table $table): Table
{
    return $table
        ->query(...)
        ->columns([
            IconColumn::make('visible_to_everyone')
                ->visible(fn (MyModel $record) => ! $record->created_by_admin) // Problem is here
        ])
  ;
}


Which throws the following error

Argument #1 ($record) must be of type App\Models\MyModel, null given, called in /var/www/endor/vendor/filament/support/src/Concerns/EvaluatesClosures.php on line 35


Am I missing something? It doesn't matter what type of column I use BTW, when I pass a closure to the visible method, it doesn't pass he record as expected.

Everything is up-to-date (LW 3.3, Filament 3.1.23)
Solution
In this case the check was on the user but I see what you mean.
I can achieve the same result by either using the trueIcon()/falseIcon() class or by conditionally adding the column. I just thought using visible would be cleaner.

Thank you both for your time 🙇‍♂️
Was this page helpful?