I've seen a variety of approaches to access entity values in the theming layer. The code below is just a simple example using magic methods. It assumes all values are set - if any part of that returns a NULL, then in my experience errors ensue.
$value = $node->field_paragraph
->entity->field_media
->entity->field_file
->entity->field_text->value;
There are methods like ->hasField
and ->count()
to check things, and i have a variety in my themes. I can get the job done but sometimes it feels ugly. I'm interested the coding patterns that devs use to safely and elegantly drill through entity references.