How to get parent node from a attachment in drupal8 search api results
$file should be instance of Drupal\file\FileInterface but in this case $file is null so you should check first on $file something 

function hook_preprocess_views_view_field(&amp;$variables) {
  $view = $variables['view'];
  $field = $variables['field'];
  if ($view-&gt;storage-&gt;id() == 'saa' &amp;&amp;
    $view-&gt;current_display == 'page_1' &amp;&amp;
    $field-&gt;field == 'fid') {
    $fid = $variables['output']-&gt;__toString();
    $file = \Drupal\file\Entity\File::load($fid);
    if ($file &amp;&amp; $file instanceof Drupal\file\FileInterface) {
      $file_usage = \Drupal::service('file.usage')-&gt;listUsage($file);
      $variables['output'] = $file_usage;
    }
  }
}