The fastest way to toggle hidden files in any window is using a built-in shortcut. This works on all modern versions of macOS, including Sierra and later.
defaults write com.apple.Finder AppleShowAllFiles true && killall Finder show hidden files mac