I think its better to use Drupal::service('masquerade')->isMasquerading() to check masquerading.
Added patch.
#patch to fix.
Himanshu5050 → created an issue.
Himanshu5050 → created an issue.
updated patch at #10 to fix access check issue.
Entity queries must explicitly set for access check in Drupal 10. Failing at paragraphs_asymmetric_translation_widgets_entity_translation_delete
Drupal\Core\Entity\EntityStorageException: Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\QueryInterface::accessCheck().
Himanshu5050 → created an issue.
Re-roll for 9.5.x
Thanks
Himanshu5050 → created an issue.