Dataview js tables not rendering in reading mode, but in live preview only

What I’m trying to do

  1. There are a bunch of files having yaml property up as a link to the file “Organic chemistry”
  2. each one has a bunch of tasks in each
  3. trying to make a table with percentages to show how many are ticked off

current code

const currentNote = dv.current().file.link
const pages = dv.array(dv.pages())
const nav_list = []
for (let i = 0; i < pages.length; i++){
if (dv.array(pages[i].up).includes(currentNote)){
nav_list.push(pages[i].file.path)
}
}
let res = []

for (let i = 0; i < nav_list.length; i++){
let curr = dv.page(nav_list[i])
let total = curr.file.tasks.length
let comp = curr.file.tasks.filter(t => t.completed).length
let p = total > 0 ? ((comp/total)*100).toFixed(2) : 0
res.push({
name: curr.file.name,
total: total,
completed: comp,
percent: p
})
}

dv.table(["File Name", "Total Tasks", "Completed Tasks", "Completion %"],res.map(r => [r.name, r.total,r.completed,r.percent]))

output in live preview

output in reading mode

what is happening and how do I fix it