I had a hard time with that as well…this is what I ended up doing but I am guessing there is probably a more elegant way. (I fumble my way through all of this)
I did like you did in your getFolderPath function, but then I saved that to localStorage so it will always stay set.
var myFolder = await require("uxp").storage.localFileSystem.getFolder();
let token = await require("uxp").storage.localFileSystem.createPersistentToken(myFolder);
localStorage.setItem("persistent-token", token);
Then when it comes time to make the file, I pull that like this:
const entry = await require("uxp").storage.localFileSystem.getEntryForPersistentToken(localStorage.getItem("persistent-token"));
const newFile = await entry.createFile("\test.tif", { overwrite: true });
const saveFile = await require("uxp").storage.localFileSystem.createSessionToken(newFile);