There seems to be a bug or undocumented behavior (at least in macOS Sequoia) where you can't unhide a file if it is inside of a hidden folder in iCloud Drive (this does not happen outside of iCloud Drive):
So, assuming you have /Users/John/Library/Mobile\ Documents/com~apple~CloudDocs/SomeDirectory/SomeFile.txt
:
You can do:
chflags hidden /Users/John/Library/Mobile\ Documents/com~apple~CloudDocs/SomeDirectory
chflags hidden /Users/John/Library/Mobile\ Documents/com~apple~CloudDocs/SomeDirectory/SomeFile.txt
And the folder AND file will be hidden. BUT if you then try to unhide just the file:
chflags nohidden /Users/John/Library/Mobile\ Documents/com~apple~CloudDocs/SomeDirectory/SomeFile.txt
It just doesn't work, even if you restart Finder or the whole device, the file stays hidden.
For some reason, you have to unhide the folder and file:
chflags nohidden /Users/John/Library/Mobile\ Documents/com~apple~CloudDocs/SomeDirectory
chflags nohidden /Users/John/Library/Mobile\ Documents/com~apple~CloudDocs/SomeDirectory/SomeFile.txt
Wait a couple of seconds (presumably for the change to be synced?), and then you can hide just the folder:
chflags hidden /Users/John/Library/Mobile\ Documents/com~apple~CloudDocs/SomeDirectory