It seems that office.js nullifies history.pushState by design see https://github.com/OfficeDev/office-js/issues/429. One solution from https://stackoverflow.com/questions/42642863/office-js-nullifies-browser-history-functions-breaking-history-usage is to cach it before calling office.js with something like this :
<script type="text/javascript">
// Office js deletes window.history.pushState and window.history.replaceState. Cache them and restore them
window._historyCache = {
replaceState: window.history.replaceState,
pushState: window.history.pushState
};
</script>
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>
<script type="text/javascript">
// Office js deletes window.history.pushState and window.history.replaceState. Restore them
window.history.replaceState = window._historyCache.replaceState;
window.history.pushState = window._historyCache.pushState;
</script>