The problem only affected one user who got the below error message; all other users were unaffected and could log in normally:
The stored procedure smCleanupFilesBeforeLogin returned the following results: DBMS: 0, Microsoft Dynamics GP: 20505.
This sort of issue is covered in a Microsoft KB article.
The first three possibilities listed, could be ruled out as they would have affected more than just one user; the final option, records stuck in either the SACTIVITY or Batch Activity (SY00800) tables.
I used the below script to check for corrupt records (the highlighted section is the user id to check for):
SELECT * FROM ACTIVITY WHERE userid = 'userid' SELECT * FROM SY00800 WHERE userid = 'userid'
Once I had confirmed the records were present, I used the below scripts to delete the stuck rows:
DELETE FROM ACTIVITY WHERE userid = 'userid' DELETE FROM SY00800 WHERE userid = 'userid'