If a shared LotusScript action calls a script library in a view that has no non-shared actions or events that use the library, then the method NotesDatabase.UnprocessedDocuments may return an empty list the first time the button is clicked. The second and subsequent clicks work.
The workaround is to add a non-shared action to the view that uses the script library containing the call to the UnprocessedDocuments method. In the Options section of the new action, create USE statements for each script library used in the shared actions.