function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Condition is not checking

I have requirement if checkbox(field level access ) is checked it will restrict the user and if checkbox is unchecked it will not restrict the user I created a method in apex and using a wire method to check the condition and if checkbox is checked it check the condition but it checkbox is unchecked it is showing error it is not checking /skiping the condition
Apex method

    public static User userData (String Ids){
        try {
            return [select id,Timesheet_Restriction_Bypass__c from user where Id =:Ids];
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());

import userData from '@salesforce/apex/FormController.userData';
import Id from '@salesforce/user/Id';
import Timesheet_Restriction_Bypass__c from '@salesforce/schema/User.Timesheet_Restriction_Bypass__c';
const fields=[Timesheet_Restriction_Bypass__c];

export default class Form extends LightningElement {
   userId = Id;
    @track error;

    @wire(userData, { Ids: '0057h000004mseIAAQ' })
    userDetails({ error, data }) {
        console.log('~~data -- ', data);
        if (data) {
            if (data.Timesheet_Restriction_Bypass__c ) {
                this.userBypass = data.Timesheet_Restriction_Bypass__c;
        }else if (error) {
            this.error = error;
  if(this.userBypass == true)
            console.log('inside worked'+this.userBypass);
        if (last2Week.isoWeekday() == 7) {
            last2Week.subtract(1, 'weeks').startOf('isoWeek');
        } else {
            last2Week.subtract(1, 'weeks').startOf('isoWeek');

Please anyone help me to find the issue.
Thanks in advance​​​​​​​