If I get the thing right, a file can be in one of the four sync presence states below:
5. Online, not available: the file (or its containing folder) is not marked as available on the local machine though OneDrive's preferences. It is not known from the Finder.
4. Not pinned: the file (or its containing folder) is marked as available (above) but not marked as "Always Keep on This Device" in the Finder. It does not show up in Spotlight but it appears in the Finder when navigating to it or opening it (with a delay). This requires fetching its data from the cloud.
3. Pinned, not discovered: same as 4, but marked as "Always Keep on This Device" in the Finder. Its data has been fetched and is available in OneDrive's cache. Same as 4: it does not show up in Spotlight but it appears in the Finder when navigating to it or opening it (with a delay). This only requires moving the data from OneDrive's cache.
2. Pinned, discovered but dataless: same as 3 but the file appears in Spotlight and in the Finder without any delay.
1. Pinned and rehydrated: same as 2 but he file's data has been retrieved from OneDrive's cache. Basically, the file (and its data) is fully local.
* I am not sure whether there is a real difference between 1 and 2, however.
I wonder why Apple's File Provider implementation (or OneDrive's use of it) still keeps pinned files in OneDrive's cache instead of simply moving them in their real locations. I don't see any performance advantage in keeping these files in the cache as they are not even stored in a different format there (which could help reducing the impact of many small files, for example). Why not simply move them and avoid having state 3 and 2 above?
While one can control in which of the above states a file is, OneDrive only allows moving between states 5-4-3 easily. States 1 and 2 can only be reached for multiple files using a script (such as the ls script mentioned multiple times). This is clearly not user friendly and causes other issues, such as what happens when new files are added to these folders. In that case one would need to constantly re-run this script to keep all files fully local. This also pushes people to try to keep all their OneDrive files away from OneDrive's cache, which somehow kills the idea behind the On-demand feature.
I have no idea if it is Microsoft or Apple's fault, but there is clearly a missing piece here that ruins the user experience for a lot of users.