For applications defined this way, the server.R file must return the server function, and the ui.R file must return the UI object (in this case, the UI object is created by fluidPage() ). In other words, if the files contained other code (like utility functions) you must make sure that the last expression in the file is the server function or UI object.
The above is also fulfilled if server.R returns a anonymous function (as long as it is the last expression in the file).
For sure you can put utility functions inside your (anonymous or named) server function. However, they are than only available in the scope of the server function and will be re-instantiated for each shiny-session. If you place them outside (above) the server function or in the global.R file they are instantiated once on app start and are globally available (which reduces time to spin up a new shiny-session).