Variable not found even though I define it JS [duplicate]

I have a loop where I add a table row. For one of the cells, the content I shows depends on an if condition. I have the variables both destructured, and then create a new variable that stores the right value, see the beginning of the code.

But somehow it does not find it, it gives the error that both “wage_displayed” is unused and also that “wage_displayed” in undefined.

Apologies, I know the code is not an MWE, but perhaps someone has a hint what it could be?

for (let i = 0; i < offers.length; i++) {
            let {job_id, wage, wage_points, wage_tokens, effort, status, employer_id, job_number} = offers[i];
            if (js_vars.currency_is_points == true) {
                let wage_displayed =  wage_points;
            } else {
                let wage_displayed =  wage_tokens;
            }
            if (status === "open") {
                let wage_displayed;
                open_offers_body.innerHTML += `<tr id="open_row_${job_id}">
                                                <td id="open_col_job_id_${job_id}"> ${job_id} </td>
                                                <td id="open_col_wage_${job_id}"> ${wage_displayed} </td>
                                                <td id="open_col_effort_${job_id}"> ${effort} </td>
                                                <td id="open_col_status_${job_id}" style="color: #008000;"> ${status} </td>
                                                <td id="open_col_employer_id_${job_id}" style="display: none"> ${employer_id} </td>
                                                <td id="open_col_job_number_${job_id}" style="display: none"> ${job_number} </td>
                                            </tr>`;
            } else if (status === "accepted") {
                accepted_offers_body.innerHTML += `<tr id="accepted_row_${job_id}">
                                                <td id="accepted_col_job_id_${job_id}"> ${job_id} </td>
                                                <td id="accepted_col_wage_${job_id}"> ${wage} </td>
                                                <td id="accepted_col_effort_${job_id}"> ${effort} </td>
                                                <td id="accepted_col_status_${job_id}" style="color: #0000CD;"> ${status} </td>
                                            </tr>`;
            }
        }