I have a better solution (I tried it and worked flawlessly).
Thanks to LegendNoobGamers
First go to your file manager and turn on hidden files (it’s usually in settings of the file manager) then go to Internal Storage>Documents>.FilesByGallery
Now there will be lots of bin/dat files (depending on your hidden files count).
For a backup purpose, copy all the files and paste it somewhere else.
Now go back to documents folder and rename the .FilesByGallery with something (like .FilesByGallery1) and then go to gallery app.
Now close the app and force stop and clear cache the gallery app. (Don’t open the app just yet)
Now go back to documents folder and rename the .FilesByGallery1 folder back to its original name (without 1).
Now close everything and open gallery and check if your hidden files are back.
If so, congratulations! 🎉
If not, you have to manually rename every bin/dat file to jpeg or mp4 and move to another location and save it in Google Photos.
I hope this helps someone.