From the code you have shared, assuming you have shared all the code added that relates to shared-element transitions, I believe you would be missing the postpone and resume shared element transitions calls.
The images we would like to transition are loaded into the grid and the pager and take time to load. To make it work properly, we will need to postpone the transition until the participating views are ready (e.g. laid out and loaded with the image data).
To do so, we call a postponeEnterTransition() in our fragments' onCreateView(), and once the image is loaded, we start the transition by calling startPostponedEnterTransition().
Note: postpone is called for both the grid and the pager fragments to support both forward and backward transitions when navigating the app.
Extra resource for deeper explanation: